Skip to content

Commit

Permalink
added lorawan records to manifest test
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscoLozCoding committed Dec 19, 2023
1 parent c252510 commit 2c3c291
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions manifests/tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def test_get_manifest(self):
[
{"hardware": "bme280", "hw_model": "BME280"},
{"hardware": "bme680", "hw_model": "BME680"},
{"hardware": "lorawan_1", "hw_model": "1"},
{"hardware": "lorawan_2", "hw_model": "2"},
]
)

self.createLorawanDevice(
[
{"deveui":"123","name":"test","hardware":"lorawan_1"},
{"deveui":"111","name":"hello","hardware":"lorawan_2"},
]
)

Expand Down Expand Up @@ -69,6 +78,26 @@ def test_get_manifest(self):
"zone": "shield",
},
],
"lorawanconnections": [
{
"connection_type": "OTAA",
"lorawandevice": {
"deveui": "123",
"hardware": {
"hardware": "lorawan_1",
}
}
},
{
"connection_type": "OTAA",
"lorawandevice": {
"deveui": "111",
"hardware": {
"hardware": "lorawan_2",
},
},
},
],
},
]
)
Expand Down Expand Up @@ -112,6 +141,26 @@ def test_get_manifest(self):
},
},
],
"lorawanconnections": [
{
"connection_type": "OTAA",
"lorawandevice": {
"deveui": "123",
"hardware": {
"hardware": "lorawan_1",
}
}
},
{
"connection_type": "OTAA",
"lorawandevice": {
"deveui": "111",
"hardware": {
"hardware": "lorawan_2",
},
},
},
],
},
)

Expand Down Expand Up @@ -154,6 +203,22 @@ def createManifests(self, manifests):
hardware=SensorHardware.objects.get(hardware=sensor),
scope=compute_obj,
)
for lc in manifest["lorawanconnections"]:
lc_obj = LorawanConnection.objects.create(
node=node_obj,
connection_type=lc["connection_type"],
lorawan_device=LorawanDevice.objects.get(deveui=lc["lorawandevice"]["deveui"])
)

def createLorawanDevice(self, device):
"""
Helper function which populates lorawan device test data.
"""
for item in device:
LorawanDevice.objects.create(
deveui=item["deveui"], name=item["name"], hardware=SensorHardware.objects.get(hardware=item["hardware"])
)


def assertManifestContainsSubset(self, item, expect):
"""
Expand Down

0 comments on commit 2c3c291

Please sign in to comment.