def setUp(self) -> None: self.hw = Hardware("Test", "Power", 100, 100) self.hw2 = Hardware("Test2", "Hevy", 200, 200) self.sw = ExpressSoftware("Sw", 10, 10) self.sw2 = ExpressSoftware("Sw1", 1, 1000) self.sw3 = ExpressSoftware("Sw2", 100000, 1) self.sw4 = ExpressSoftware("Sw3", 1000000, 1000000)
def test_not_working_install_message(self): software = Software("Skype", "Express", 100, 10) self.hardware = Hardware("SSD", "Heavy", 10, 12) try: self.hardware.install(software) except Exception as ex: self.assertEqual(str(ex), "Software cannot be installed")
def test_uninstall_method(self): hardware = Hardware('test', 'SSD', 512, 16) software = LightSoftware('test', 10, 5) hardware.install(software) self.assertEqual(len(hardware.software_components), 1) hardware.uninstall(software) self.assertEqual(len(hardware.software_components), 0)
def test_init(self): hw = Hardware('n', 'Express', 5, 10) self.assertEqual(hw.name, 'n') self.assertEqual(hw.type, 'Express') self.assertEqual(hw.capacity, 5) self.assertEqual(hw.memory, 10) self.assertListEqual(hw.software_components, [])
def test_phardware__init__(self): self.hardware = Hardware("Docking Station", "Power", 3000, 5500) self.assertEqual(self.hardware.name, "Docking Station") self.assertEqual(self.hardware.type, "Power") self.assertEqual(self.hardware.capacity, 3000) self.assertEqual(self.hardware.memory, 5500) self.assertEqual(self.hardware.software_components, [])
def test_init(self): hw = Hardware('name', 'type', 1000, 512) self.assertEqual('name', hw.name) self.assertEqual('type', hw.type) self.assertEqual(1000, hw.capacity) self.assertEqual(512, hw.memory) self.assertEqual(0, len(hw.software_components))
def test_uninstall(self): hard = Hardware('h1', 'test', 100, 100) s1 = Software('win', 'Express', 10, 10) hard.install(s1) hard.uninstall(s1) self.assertEqual([], hard.software_components) self.assertListEqual([], hard.software_components)
def test_install(self): hard = Hardware('h1', 'test', 100, 100) s1 = Software('win', 'Express', 120, 120) with self.assertRaises(Exception) as context: hard.install(s1) self.assertEqual(str(context.exception), 'Software cannot be installed')
def test_HardwareInitialization(self): hardware = Hardware('Test', 'Heavy', 100, 200) self.assertEqual(hardware.name, 'Test') self.assertEqual(hardware.type, 'Heavy') self.assertEqual(hardware.capacity, 100) self.assertEqual(hardware.memory, 200) self.assertEqual(len(hardware.software_components), 0)
def test_hhardware__init__(self): self.hardware = Hardware("Server", "Heavy", 5000, 3500) self.assertEqual(self.hardware.name, "Server") self.assertEqual(self.hardware.type, "Heavy") self.assertEqual(self.hardware.capacity, 5000) self.assertEqual(self.hardware.memory, 3500) self.assertEqual(self.hardware.software_components, [])
def test_uninstall(self): hw = Hardware('name', 'type', 1000, 512) sw = ExpressSoftware('test', 100, 100) hw.install(sw) self.assertEqual(1, len(hw.software_components)) hw.uninstall(sw) self.assertEqual(0, len(hw.software_components))
def test_install_soft_raise_ex_when_capacity_or_memory_not_enough(self): with self.assertRaises(Exception) as ex: hardware = Hardware('test', 'SSD', 512, 16) software = LightSoftware('test', 550, 20) hardware.install(software) self.assertIsNotNone(ex.exception)
def test_attributes(self): hard = Hardware('hard', 'test', 100, 100) self.assertEqual('hard', hard.name) self.assertEqual('test', hard.type) self.assertEqual(100, hard.memory) self.assertEqual(100, hard.capacity) self.assertEqual([], hard.software_components) self.assertListEqual([], hard.software_components)
def test_install_method_raising_exception_capacity_failure( self): # Capacity failure self.hardware = Hardware("Server", "Heavy", 250, 100) self.software = Software("Linux", "Express", 100, 200) with self.assertRaises(Exception, msg="Software cannot be installed") as exc: self.hardware.install(self.software) self.assertEqual(str(exc.exception), exc.msg)
def setUp(self) -> None: self.hardware = Hardware('test_hardware', 'Power', 100, 200)
def setUp(self): self.hardware = Hardware("test", "test_type", 10, 100) self.power_hardware = PowerHardware("power", 20, 50) self.heavy_hardware = HeavyHardware("heavy", 20, 50) self.light_software = LightSoftware("light", 10, 10) self.express_software = ExpressSoftware("express", 10, 10)
def test_install_soft_when_capacity_or_memory_enough(self): hardware = Hardware('test', 'SSD', 512, 16) software = LightSoftware('test', 10, 5) hardware.install(software) self.assertEqual(len(hardware.software_components), 1)
def setUp(self): self.hardware = Hardware('Test hardware', 'Heavy', 100, 10)
def test_set_attr(self): hardware = Hardware('test', 'SSD', 512, 16) self.assertEqual(hardware.name, 'test') self.assertEqual(hardware.type, 'SSD') self.assertEqual(hardware.capacity, 512) self.assertEqual(hardware.memory, 16)
def setUp(self): self.hw = Hardware('name', 'type', 100, 1000)
def setUp(self): self.h = Hardware("Lenovo", "Power", 800, 32) self.s = Software("Win", "Light", 10, 20) self.e = Software("Win", "Express", 1000, 2000)
def setUp(self): self.hardware = Hardware('Test', 'Power', 100, 100)
def setUp(self): self.hardware = Hardware("Intel", "Heavy", 100, 100)
def setUp(self) -> None: self.hardware = Hardware("SSD", "Light", 1000, 1000)
def test_HardwareInitialization_with_wrong_type_shouldRaise(self): with self.assertRaises(Exception) as context: Hardware('Test', 'Big', 100, 200) self.assertIsNotNone(context.exception)
def setUp(self): self.hardware = Hardware("Intel", "Power", 100, 200)
def setUp(self): self.hardware = Hardware(name='HDD', type='PowerHardware', capacity=200, memory=200) self.software = Software("HDD", "LightSoftware", 0, 10)
def setUp(self): self.hardware = Hardware("HDD", "Heavy", 600, 600) self.software_one = LightSoftware("INIT", 100, 300) self.software_just_in = ExpressSoftware("Win", 450, 225) self.software_not_enough_space = LightSoftware("Linux", 100, 100) self.software_too_big = ExpressSoftware("MacOS", 1000, 1000)
def setUp(self) -> None: self.test_hardware = Hardware('Test_name', 'Heavy', 100, 100)
def setUp(self): self.hardware = Hardware("SSD", "Heavy", 100, 120)