|
| 1 | +""" |
| 2 | +Test assets creation |
| 3 | +""" |
| 4 | + |
| 5 | +from copy import deepcopy |
| 6 | +from os import environ |
| 7 | +from unittest import TestCase |
| 8 | + |
| 9 | +from archivist.archivist import Archivist |
| 10 | +from archivist.storage_integrity import StorageIntegrity |
| 11 | + |
| 12 | +# pylint: disable=fixme |
| 13 | +# pylint: disable=missing-docstring |
| 14 | +# pylint: disable=unused-variable |
| 15 | + |
| 16 | +BEHAVIOURS = [ |
| 17 | + "RecordEvidence", |
| 18 | + "Attachments", |
| 19 | +] |
| 20 | +ATTRS = { |
| 21 | + "arc_firmware_version": "1.0", |
| 22 | + "arc_serial_number": "vtl-x4-07", |
| 23 | + "arc_description": "Traffic flow control light at A603 North East", |
| 24 | + "arc_home_location_identity": "locations/115340cf-f39e-4d43-a2ee-8017d672c6c6", |
| 25 | + "arc_display_type": "Traffic light with violation camera", |
| 26 | + "some_custom_attribute": "value", |
| 27 | +} |
| 28 | + |
| 29 | + |
| 30 | +class TestAssetCreate(TestCase): |
| 31 | + """ |
| 32 | + Test Archivist Asset Create method |
| 33 | + """ |
| 34 | + |
| 35 | + maxDiff = None |
| 36 | + |
| 37 | + def setUp(cls): |
| 38 | + with open(environ["TEST_AUTHTOKEN"]) as fd: |
| 39 | + auth = fd.read().strip() |
| 40 | + cls.arch = Archivist(environ["TEST_ARCHIVIST"], auth=auth, verify=False) |
| 41 | + cls.attrs = deepcopy(ATTRS) |
| 42 | + |
| 43 | + def test_asset_create_tenant_storage(self): |
| 44 | + """ |
| 45 | + Test asset creation on tenant storage |
| 46 | + """ |
| 47 | + asset = self.arch.assets.create( |
| 48 | + BEHAVIOURS, |
| 49 | + self.attrs, |
| 50 | + confirm=True, |
| 51 | + ) |
| 52 | + self.assertEqual( |
| 53 | + asset["storage_integrity"], |
| 54 | + StorageIntegrity.TENANT_STORAGE.name, |
| 55 | + msg="Incorrect asset storage integrity", |
| 56 | + ) |
| 57 | + |
| 58 | + def test_asset_create_ledger(self): |
| 59 | + """ |
| 60 | + Test asset creation on ledger |
| 61 | + """ |
| 62 | + asset = self.arch.assets.create( |
| 63 | + BEHAVIOURS, |
| 64 | + self.attrs, |
| 65 | + storage_integrity=StorageIntegrity.LEDGER, |
| 66 | + confirm=True, |
| 67 | + ) |
| 68 | + self.assertEqual( |
| 69 | + asset["storage_integrity"], |
| 70 | + StorageIntegrity.LEDGER.name, |
| 71 | + msg="Incorrect asset storage integrity", |
| 72 | + ) |
0 commit comments