def test_can_reset_list_of_hardware_identifiers(self): manager = SupportedHardwareManager() manager.add('h1') manager.add('h2') self.assertEqual(len(manager), 2) manager.reset() self.assertEqual(len(manager), 0)
def test_can_add_hardware_identifier(self): manager = SupportedHardwareManager() hardware = 'PowerX' self.assertEqual(len(manager), 0) manager.add(hardware) self.assertEqual(len(manager), 1) self.assertIn(hardware, manager)
def test_can_serialize_as_metadata_when_some(self): manager = SupportedHardwareManager() manager.add('PowerZ') manager.add('PowerY') manager.add('PowerX') expected = {'supported-hardware': ['PowerX', 'PowerY', 'PowerZ']} observed = manager.to_metadata() self.assertEqual(observed, expected)
def test_can_compare_managers(self): manager1 = SupportedHardwareManager() manager2 = SupportedHardwareManager() self.assertEqual(manager1, manager2) manager1.add('hardware') self.assertNotEqual(manager1, manager2) manager2.add('hardware') self.assertEqual(manager1, manager2)
def test_can_serialize_manager_as_string_when_some(self): manager = SupportedHardwareManager() manager.add('PowerX') manager.add('PowerY') manager.add('PowerZ') with open('tests/core/fixtures/hardware/string_some.txt') as fp: expected = fp.read().strip() observed = str(manager) self.assertEqual(observed, expected)
def test_can_remove_hardware_identifier(self): manager = SupportedHardwareManager() manager.add('PowerX') manager.add('PowerY') self.assertEqual(len(manager), 2) manager.remove('PowerX') self.assertEqual(len(manager), 1) manager.remove('PowerY') self.assertEqual(len(manager), 0)
def create_package(self): pkg = Package(version=self.version, product=self.product) pkg.objects.create(self.obj_options) pkg.supported_hardware.add(self.hardware) # control supported hardware hw = SupportedHardwareManager() hw.add(self.hardware) # control objects objs = ObjectsManager() objs.create(self.obj_options) return pkg, hw, objs
def test_can_serialize_as_template_when_some(self): manager = SupportedHardwareManager() manager.add('PowerX') expected = {'supported-hardware': ['PowerX']} observed = manager.to_template() self.assertEqual(expected, observed)
def test_cant_add_same_hardware_identifier_twice(self): manager = SupportedHardwareManager() manager.add('PowerX') manager.add('PowerX') self.assertEqual(len(manager), 1)