resolve conflict

This commit is contained in:
Cayo Puigdefabregas 2021-06-11 12:52:39 +02:00
commit ab32b996bd
9 changed files with 65 additions and 41 deletions

View File

@ -12,6 +12,7 @@ ml).
[1.0.7-beta]
## [1.0.7-beta]
- [addend] #135 adding trade system
- [addend] #140 adding endpoint for download the settings for usb workbench
## [1.0.6-beta]

View File

@ -44,6 +44,8 @@ class DevicehubConfig(Config):
host=DB_HOST,
db=DB_DATABASE,
) # type: str
SCHEMA = config('SCHEMA', 'dbtest')
HOST = config('HOST', 'localhost')
MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion
"""The minimum version of ereuse.org workbench that this devicehub
accepts. we recommend not changing this value.

View File

@ -1486,7 +1486,6 @@ class Trade(JoinedTableMixin, ActionWithMultipleDevices):
This class and its inheritors
extend `Schema's Trade <http://schema.org/TradeAction>`_.
"""
# id = Column(UUID(as_uuid=True), primary_key=True, default=uuid4)
user_from_id = db.Column(UUID(as_uuid=True),
db.ForeignKey(User.id),
nullable=False)

View File

@ -44,8 +44,10 @@ class DeviceRow(OrderedDict):
# General information about device
self['DevicehubID'] = device.devicehub_id
self['DocumentID'] = self.document_id
self['Public Link'] = '{url}{id}'.format(url=url_for('Device.main', _external=True),
self['Public Link'] = '{url}{id}'.format(
url=url_for('Device.main', _external=True),
id=device.devicehub_id)
self['Lots'] = ', '.join([x.name for x in self.device.lots])
self['Tag 1 Type'] = self['Tag 1 ID'] = self['Tag 1 Organization'] = ''
self['Tag 2 Type'] = self['Tag 2 ID'] = self['Tag 2 Organization'] = ''
self['Tag 3 Type'] = self['Tag 3 ID'] = self['Tag 3 Organization'] = ''

View File

@ -1,6 +1,7 @@
import csv
import enum
import uuid
import time
import datetime
import pathlib
from collections import OrderedDict
@ -22,6 +23,7 @@ from teal.resource import Resource, View
from ereuse_devicehub import auth
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.enums import SessionType
from ereuse_devicehub.resources.user.models import Session
from ereuse_devicehub.resources.action import models as evs
from ereuse_devicehub.resources.device import models as devs
from ereuse_devicehub.resources.deliverynote.models import Deliverynote
@ -323,8 +325,8 @@ class WbConfDocumentView(DeviceView):
return jsonify('')
data = {'token': self.get_token(),
'host': app.config['DB_HOST'],
'inventory': app.config['DB_SCHEMA']
'host': app.config['HOST'],
'inventory': app.config['SCHEMA']
}
data['erase'] = False
# data['erase'] = True if wbtype == 'usodywipe' else False
@ -336,7 +338,20 @@ class WbConfDocumentView(DeviceView):
return output
def get_token(self):
tk = [s.token for s in g.user.sessions if s.type == SessionType.Internal][0]
if not g.user.sessions:
ses = Session(user=g.user)
db.session.add(ses)
db.session.commit()
tk = ''
now = time.time()
for s in g.user.sessions:
if s.type == SessionType.Internal and (s.expired == 0 or s.expired > now):
tk = s.token
break
assert tk != ''
token = auth.Auth.encode(tk)
return token

View File

@ -1,17 +1,19 @@
[settings]
DH_TOKEN="{{token}}"
DH_TOKEN = {{token}}
DH_HOST="{{host}}"
DH_DATABASE="{{inventory}}"
DEVICEHUB_URL=https://${DB_HOST}/${DB_DATABASE}/
DH_HOST = {{host}}
DH_DATABASE = {{inventory}}
DEVICEHUB_URL = https://${DB_HOST}/${DB_DATABASE}/
WB_BENCHMARK = False
WB_STRESS_TEST = 0
WB_SMART_TEST = ""
WB_ERASE = {{erase}}
WB_BENCHMARK = True
WB_STRESS_TEST = 1
WB_SMART_TEST = short
WB_ERASE =
WB_ERASE_STEPS = 1
WB_ERASE_LEADING_ZEROS = False
WB_DEBUG = True
WB_DEBUG = False

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -220,13 +220,13 @@ def test_export_basic_snapshot(user: UserClient):
obj_csv = csv.reader(csv_file, delimiter=';', quotechar='"')
fixture_csv = list(obj_csv)
assert isinstance(datetime.strptime(export_csv[1][18], '%c'), datetime), \
assert isinstance(datetime.strptime(export_csv[1][19], '%c'), datetime), \
'Register in field is not a datetime'
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1][:18] == export_csv[1][:18], 'Computer information are not equal'
assert fixture_csv[1][19] == export_csv[1][19], 'Computer information are not equal'
assert fixture_csv[1][21:] == export_csv[1][21:], 'Computer information are not equal'
assert fixture_csv[1][:19] == export_csv[1][:19], 'Computer information are not equal'
assert fixture_csv[1][20] == export_csv[1][20], 'Computer information are not equal'
assert fixture_csv[1][22:] == export_csv[1][22:], 'Computer information are not equal'
@pytest.mark.mvp
@ -275,30 +275,33 @@ def test_export_extended(app: Devicehub, user: UserClient):
obj_csv = csv.reader(f, f, delimiter=';', quotechar='"')
export_csv = list(obj_csv)
ff= open('ba.csv', 'w')
ff.write(csv_str)
ff.close()
# Open fixture csv and transform to list
with Path(__file__).parent.joinpath('files').joinpath(
'proposal_extended_csv_report.csv').open() as csv_file:
obj_csv = csv.reader(csv_file, delimiter=';', quotechar='"')
fixture_csv = list(obj_csv)
assert isinstance(datetime.strptime(export_csv[1][18], '%c'), datetime), \
assert isinstance(datetime.strptime(export_csv[1][19], '%c'), datetime), \
'Register in field is not a datetime'
assert fixture_csv[0] == export_csv[0], 'Headers are not equal'
assert fixture_csv[1][:18] == export_csv[1][:18], 'Computer information are not equal'
assert fixture_csv[1][19] == export_csv[1][19], 'Computer information are not equal'
assert fixture_csv[1][21:80] == export_csv[1][21:80], 'Computer information are not equal'
assert fixture_csv[1][81] == export_csv[1][81], 'Computer information are not equal'
assert fixture_csv[1][84:] == export_csv[1][84:], 'Computer information are not equal'
assert fixture_csv[2][:18] == export_csv[2][:18], 'Computer information are not equal'
assert fixture_csv[2][19] == export_csv[2][19], 'Computer information are not equal'
assert fixture_csv[2][21:80] == export_csv[2][21:80], 'Computer information are not equal'
assert fixture_csv[2][81] == export_csv[2][81], 'Computer information are not equal'
assert fixture_csv[2][84:104] == export_csv[2][84:104], 'Computer information are not equal'
assert fixture_csv[2][105] == export_csv[2][105], 'Computer information are not equal'
assert fixture_csv[2][108:128] == export_csv[2][108:128], 'Computer information are not equal'
assert fixture_csv[2][129] == export_csv[2][129], 'Computer information are not equal'
assert fixture_csv[2][132:] == export_csv[2][132:], 'Computer information are not equal'
assert fixture_csv[1][:19] == export_csv[1][:19], 'Computer information are not equal'
assert fixture_csv[1][20] == export_csv[1][20], 'Computer information are not equal'
assert fixture_csv[1][22:81] == export_csv[1][22:81], 'Computer information are not equal'
assert fixture_csv[1][82] == export_csv[1][82], 'Computer information are not equal'
assert fixture_csv[1][85:] == export_csv[1][85:], 'Computer information are not equal'
assert fixture_csv[2][:19] == export_csv[2][:19], 'Computer information are not equal'
assert fixture_csv[2][20] == export_csv[2][20], 'Computer information are not equal'
assert fixture_csv[2][22:81] == export_csv[2][22:81], 'Computer information are not equal'
assert fixture_csv[2][82] == export_csv[2][82], 'Computer information are not equal'
assert fixture_csv[2][85:105] == export_csv[2][85:105], 'Computer information are not equal'
assert fixture_csv[2][106] == export_csv[2][106], 'Computer information are not equal'
assert fixture_csv[2][109:129] == export_csv[2][109:129], 'Computer information are not equal'
assert fixture_csv[2][130] == export_csv[2][130], 'Computer information are not equal'
assert fixture_csv[2][133:] == export_csv[2][133:], 'Computer information are not equal'
@pytest.mark.mvp
@ -656,10 +659,10 @@ def test_get_wbconf(user: UserClient):
"""Tests for get env file for usb wb."""
env, _ = user.get(res=documents.DocumentDef.t, item='wbconf/usodyrate', accept=ANY)
assert 'WB_ERASE = False' in env
assert 'WB_ERASE =' in env
env, _ = user.get(res=documents.DocumentDef.t, item='wbconf/usodywipe', accept=ANY)
assert 'WB_ERASE = False' in env
assert 'WB_ERASE =' in env
# assert 'WB_ERASE = True' in env
session = Session.query.filter_by(user_id=user.user['id'],