def test__get_merged_version_data_missing_entity(self): fake1 = { "component1": { "name": "foo", "version": "NA", "hash_value": "blahblah" }, "component2": { "name": "foo2", "version": "any", "hash_value": "blahblah" }, } fake2 = { "component1": { "entities": ["1", "2", "3", "4", "5", "6", "7", "8"], "get_version": "NA", }, "component3": { "entities": ["1", "2", "3", "4", "5", "6", "7", "8"], "get_version": "NA", }, } with self.assertRaises(Exception): fw_json.FwJson()._get_merged_version_data(fake1, fake2)
def test__get_json_filename(self, mocked_listdir): """ Test *_fw_versions.json is in cwd """ mocked_listdir.return_value = ["blah", "blah2.json"] with self.assertRaises(Exception): fw_json.FwJson()._get_json_filename(endpattern="_fw_versions.json")
def test__fetch_fw_manifest_with_versions_json(self, mocked_listdir): """ Test *_fw_manifest.json is in cwd but testing for versions """ mocked_listdir.return_value = ["blah", "blah2_fw_manifest.json"] with self.assertRaises(Exception): fw_json.FwJson()._get_json_filename(endpattern="_fw_versions.json")
def test__filter_fw_entities(self): fake1 = { "component1": { "name": "foo", "version": "NA", "hash_value": "blahblah" }, "component2": { "name": "foo2", "version": "any", "hash_value": "blahblah" }, "component3": { "name": "foo2", "version": "any", "hash_value": "blahblah" }, } fake2 = { "component1": { "entities": ["1", "2", "3", "4", "5", "6", "7", "8"], "get_version": "NA", }, "component2": { "get_version": "blah blah", "priority": "4", "upgrade_cmd": "blah blah blah", }, "component3": { "entities": ["1", "2", "3", "4", "5", "6", "7", "8"], "get_version": "NA", }, } merged_data = self.fw._get_merged_version_data(fake1, fake2) result = fw_json.FwJson(binarypath=mock, fw_entity=["component2", "component3" ])._filter_fw_entities(merged_data) self.assertNotIn("component1", result) self.assertIn("component2", result) self.assertIn("component3", result)
def setUp(self): self.fw = fw_json.FwJson(binarypath=mock)