add test for erasure list view
This commit is contained in:
parent
ff765f38f8
commit
e02644f75c
|
@ -121,13 +121,9 @@ class ErasureListView(DeviceListMixin):
|
||||||
return flask.render_template(self.template_name, **self.context)
|
return flask.render_template(self.template_name, **self.context)
|
||||||
|
|
||||||
def get_devices(self):
|
def get_devices(self):
|
||||||
erasure = EraseBasic.query.filter_by(author=g.user)
|
erasure = EraseBasic.query.filter_by(author=g.user).order_by(
|
||||||
# ids = [ac.device.id for ac in actions]
|
EraseBasic.created.desc()
|
||||||
# devices = Device.query.filter(Device.owner_id == g.user.id).filter(
|
)
|
||||||
# Device.id.in_(ids)
|
|
||||||
# # Device.binding == None # noqa: E711
|
|
||||||
# )
|
|
||||||
# self.context['devices'] = devices
|
|
||||||
self.context['erasure'] = erasure
|
self.context['erasure'] = erasure
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
<td>
|
<td>
|
||||||
{{ ac.severity }}
|
{{ ac.severity }}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ ac.date_str }}</td>
|
<td>{{ ac.created.strftime('%Y-%m-%d %H:%M:%S')}}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('inventory.export', export_id='snapshot') }}?id={{ ac.snapshot.id }}">
|
<a href="{{ url_for('inventory.export', export_id='snapshot') }}?id={{ ac.snapshot.id }}">
|
||||||
<i class="bi bi-box-arrow-up-right"></i>
|
<i class="bi bi-box-arrow-up-right"></i>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"version": "11.0a3",
|
"version": "11.0a3",
|
||||||
"device": {
|
"device": {
|
||||||
"serialNumber": 'foo',
|
"serialNumber": "foo",
|
||||||
"manufacturer": 'bar',
|
"manufacturer": "bar",
|
||||||
"model": 'baz',
|
"model": "baz",
|
||||||
"type": "Desktop",
|
"type": "Desktop",
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"chassis": "Tower"
|
"chassis": "Tower"
|
||||||
|
|
|
@ -2295,3 +2295,32 @@ def test_upload_snapshot_smartphone(user3: UserClientFlask):
|
||||||
assert dev.binding.device.serial_number == 'abcdef'
|
assert dev.binding.device.serial_number == 'abcdef'
|
||||||
assert dev.placeholder is None
|
assert dev.placeholder is None
|
||||||
assert len(dev.actions) == 2
|
assert len(dev.actions) == 2
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.mvp
|
||||||
|
@pytest.mark.usefixtures(conftest.app_context.__name__)
|
||||||
|
def test_list_erasures(user3: UserClientFlask):
|
||||||
|
uri = '/inventory/upload-snapshot/'
|
||||||
|
file_name = 'erase-sectors-2-hdd.snapshot.yaml'
|
||||||
|
body, status = user3.get(uri)
|
||||||
|
|
||||||
|
assert status == '200 OK'
|
||||||
|
assert "Select a Snapshot file" in body
|
||||||
|
|
||||||
|
snapshot = conftest.yaml2json(file_name.split(".yaml")[0])
|
||||||
|
b_snapshot = bytes(json.dumps(snapshot), 'utf-8')
|
||||||
|
file_snap = (BytesIO(b_snapshot), file_name)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'snapshot': file_snap,
|
||||||
|
'csrf_token': generate_csrf(),
|
||||||
|
}
|
||||||
|
|
||||||
|
user3.post(uri, data=data, content_type="multipart/form-data")
|
||||||
|
|
||||||
|
uri = '/inventory/device/erasure/'
|
||||||
|
body, status = user3.get(uri)
|
||||||
|
|
||||||
|
txt = "WD-WCAV27984668"
|
||||||
|
assert status == '200 OK'
|
||||||
|
assert txt in body
|
||||||
|
|
Reference in New Issue