Example #1
0
 def test_unsuccessful_uninstall(self):
     soft = Software("Skype", "Express", 60, 40)
     softy = Software("Discord", "Express", 20, 20)
     self.hardware.install(soft)
     with self.assertRaises(Exception) as ex:
         self.hardware.uninstall(softy)
         self.assertEqual(str(ex), "Some of the components do not exist")
Example #2
0
 def test_hardware_install_with_valid_software_obj__should_add_it_to_software_components(
         self):
     light_software = Software('test', 'Light', 10, 10)
     test_software = Software('test_express', 'Express', 10, 10)
     self.test_hardware.install(light_software)
     self.assertEqual(1, len(self.test_hardware.software_components))
     self.test_hardware.install(test_software)
     self.assertEqual(2, len(self.test_hardware.software_components))
Example #3
0
    def test_install(self):
        software = Software('MS', 'type', 5, 5)
        self.hardware.install(software)
        self.assertEqual(self.hardware.software_components, [software])

        software = Software('MS', 'type', 15, 15)
        with self.assertRaises(Exception) as cm:
            self.hardware.install(software)
        self.assertEqual(str(cm.exception), "Software cannot be installed")
Example #4
0
 def test_install_sw_unsuccessful(self):
     sw = Software('name', 'Light', 110, 20)
     with self.assertRaises(Exception) as exc1:
         self.hw.install(sw)
     self.assertEqual('Software cannot be installed', str(exc1.exception))
     sw1 = Software('name', 'Light', 20, 120)
     with self.assertRaises(Exception) as exc2:
         self.hw.install(sw1)
     self.assertEqual('Software cannot be installed', str(exc2.exception))
Example #5
0
    def test_HardwareUninstall(self):
        test_software = Software('TestSoftware', 'Light', 20, 30)
        test_software2 = Software('TestSoftware2', 'Light', 10, 30)

        self.hardware.install(test_software)
        self.hardware.install(test_software2)
        self.hardware.uninstall(test_software)
        self.assertEqual(len(self.hardware.software_components), 1)
        self.hardware.uninstall(test_software2)
        self.assertEqual(len(self.hardware.software_components), 0)
    def test_install_should_raise_error_when_there_is_not_enough_memory_or_capacity(
            self):
        software = Software('Windows', 'Software', 110, 110)

        with self.assertRaises(Exception) as cm:
            self.hardware.install(software)
        self.assertEqual(str(cm.exception), "Software cannot be installed")
 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_three(self):
        programa = Software('Test', 'Express', 5, 5)

        self.kompiutur.install(programa)
        self.kompiutur.uninstall(programa)

        self.assertListEqual([], self.kompiutur.software_components)
Example #9
0
 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")
Example #10
0
    def test_install_method_when_capacity_and_memory_enough(self):
        sw = Software('Linux', 'os', 4, 4)
        self.hw.install(sw)
        result = self.hw.software_components[0]
        expected = 'Linux'

        self.assertEqual(result.name, expected)
Example #11
0
    def test_install_method_when_capacity_and_memory_not_enough_for_software_should_raises(
            self):
        sw = Software('Linux', 'os', 5, 4)
        with self.assertRaises(Exception) as ex:
            self.hw.install(sw)

        self.assertIsNotNone(str(ex.exception))
Example #12
0
 def test_hardware__no_memory_when_software_is_installed__expect_exception(
         self):
     software = Software("Win10", "Light", 501, 501)
     with self.assertRaises(Exception) as context:
         self.hardware.install(software)
     self.assertEqual("Software cannot be installed",
                      str(context.exception))
Example #13
0
    def test_install_should_raise_error_if_capacity_or_memory_are_more_than_the_hardware_ones(
            self):
        software = Software('Windows', 'OS', 150, 150)

        with self.assertRaises(Exception) as cm:
            self.hardware.install(software)
        self.assertEqual(str(cm.exception), "Software cannot be installed")
 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_uninstall_should_not_remove_the_software_if_it_is_not_in_the_software_components(
            self):
        software = Software('Windows', 'Software', 100, 100)
        self.hardware.install(software)

        self.assertEqual(len(self.hardware.software_components), 1)
        self.hardware.uninstall(software)
        self.assertEqual(len(self.hardware.software_components), 0)
Example #16
0
    def test_install__when_capacity_invalid_and_memory_invalid__expect_exception(
            self) -> None:
        software = Software('Manjaro', 'OS', 1024, 256)
        with self.assertRaises(Exception) as context:
            self.hardware.install(software)

        self.assertEqual(context.exception.args[0],
                         'Software cannot be installed')
Example #17
0
    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)
Example #18
0
    def test_HardwareInstall_whenNotEnoughCapacityAndMemory_shouldRaise(self):
        test_software = Software('TestSoftware', 'Light', 200, 300)

        with self.assertRaises(Exception) as context:
            self.hardware.install(test_software)

        self.assertIsNotNone(context.exception)
        self.assertEqual(context.exception.__str__(),
                         "Software cannot be installed")
Example #19
0
    def test_hardware_install_software__when_possible_expect_to_decrease_hardware_memory_and_capacity(
            self):
        software = Software("Windows", "Light", 50, 10)
        self.hardware.install(software)

        expected_capacity = 150
        expected_memory = 190
        self.assertEqual(expected_capacity, self.hardware.capacity)
        self.assertEqual(expected_memory, self.hardware.memory)
Example #20
0
    def test_hardware_uninstall__expect_to_increase_hardware_memory_and_capacity(
            self):
        software = Software("Windows", "Light", 50, 10)
        self.hardware.install(software)
        self.hardware.uninstall(software)

        expected_capacity = 200
        expected_memory = 200
        self.assertEqual(expected_capacity, self.hardware.capacity)
        self.assertEqual(expected_memory, self.hardware.memory)
Example #21
0
 def test_install_should_add_software_to_the_software_components(self):
     software = Software('Windows', 'Light', 50, 50)
     self.hardware.install(software)
     self.assertEqual(len(self.hardware.software_components), 1)
Example #22
0
 def test_uninstall(self):
     soft = Software("Skype", "Express", 60, 40)
     self.hardware.install(soft)
     self.hardware.uninstall(soft)
     self.assertEqual(self.hardware.software_components, [])
 def setUp(self):
     self.h = Hardware("Lenovo", "Power", 800, 32)
     self.s = Software("Win", "Light", 10, 20)
     self.e = Software("Win", "Express", 1000, 2000)
Example #24
0
    def test_hardware_install_when_not_enough_capacity__should_raise(self):
        light_software = Software('test', 'Light', 1000, 10)
        with self.assertRaises(Exception) as ex:
            self.test_hardware.install(light_software)

        self.assertEqual("Software cannot be installed", str(ex.exception))
Example #25
0
 def test_uninstall_should_remove_software_from_the_software_components(
         self):
     software = Software('Windows', 'OS', 25, 25)
     self.hardware.install(software)
     self.hardware.uninstall(software)
     self.assertEqual(len(self.hardware.software_components), 0)
Example #26
0
 def test_successful_install(self):
     soft = Software("Skype", "Express", 60, 40)
     self.hardware.install(soft)
     self.assertEqual(len(self.hardware.software_components), 1)
Example #27
0
 def test_uninstall(self):
     software = Software("Mozilla", "browser", 200, 200)
     self.hardware.install(software)
     self.hardware.uninstall(software)
     self.assertEqual([], self.hardware.software_components)
Example #28
0
 def test_unsuccessful_install(self):
     soft = Software("NotSkype", "Express", 200, 240)
     with self.assertRaises(Exception) as ex:
         self.hardware.install(soft)
         self.assertEqual(str(ex), "Software cannot be installed")
Example #29
0
 def test_hardware_uninstall__should_remove_from_software_components(self):
     light_software = Software('test', 'Light', 10, 10)
     self.test_hardware.install(light_software)
     self.test_hardware.uninstall(light_software)
     self.assertEqual(0, len(self.test_hardware.software_components))
Example #30
0
 def setUp(self):
     self.hardware = Hardware(name='HDD',
                              type='PowerHardware',
                              capacity=200,
                              memory=200)
     self.software = Software("HDD", "LightSoftware", 0, 10)