Esempio n. 1
0
    def test_purchased(self):
        name = 'Intel Core i9-9900'
        manufacturer = 'Intel'
        total = 80
        allocated = 76

        n = 20
        purchased_total = total + n
        r = Resource(name, manufacturer, total, allocated)
        r_purchased = Resource(name, manufacturer, purchased_total, allocated)
        self.assertEqual(r_purchased.total, r.purchased(n).total)
Esempio n. 2
0
    def test_claim(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 'AMD'
        total = 50
        allocated = 41

        n = 10
        claim_ = allocated - n
        r = Resource(name, manufacturer, total, allocated)
        r_claim = Resource(name, manufacturer, total, claim_)
        self.assertEqual(r_claim.allocated, r.claim(n).allocated)
Esempio n. 3
0
    def test_freeup(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 'AMD'
        total = 50
        allocated = 41

        n = 7
        freeup_ = allocated + n
        r = Resource(name, manufacturer, total, allocated)
        r_freeup = Resource(name, manufacturer, total, freeup_)
        self.assertEqual(r_freeup.allocated, r.freeup(n).allocated)
Esempio n. 4
0
    def test_repr(self):
        name = 'Intel Core i9-9900'
        manufacturer = 'Intel'
        total = 41
        allocated = 40

        repr_r = (f'Resource(name={name}, '
                  f'manufacturer={manufacturer}, '
                  f'total={total}, '
                  f'allocated={allocated})')

        r = Resource(name, manufacturer, total, allocated)
        self.assertEqual(repr_r, r.__repr__())
Esempio n. 5
0
    def test_died(self):
        name = 'Intel Core i9-9900'
        manufacturer = 'Intel'
        total = 80
        allocated = 76

        n = 11
        died_total = total - n
        died_allocated = allocated - n

        r = Resource(name, manufacturer, total, allocated)
        r_died = Resource(name, manufacturer, died_total, died_allocated)
        self.assertEqual(r_died.total,
                         r.died(n).total)  # increase total and allocated
        self.assertEqual(r_died.allocated - n, r.died(n).allocated)
Esempio n. 6
0
    def test_allocated_negative(self):
        name = 'Intel LGA1151 i7-9700K'
        manufacturer = 'Intel'
        total = 26
        allocated = -26

        with self.assertRaises(ResourceError):
            r = Resource(name, manufacturer, total, allocated)
Esempio n. 7
0
    def test_allocated_greater_then_total(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 'AMD'
        total = 39
        allocated = 41

        with self.assertRaises(ResourceError):
            r = Resource(name, manufacturer, total, allocated)
Esempio n. 8
0
    def test_total_real(self):
        name = 'Intel LGA1151 i7-9700K'
        manufacturer = 'Intel'
        total = 26.01
        allocated = 26

        with self.assertRaises(ResourceError):
            r = Resource(name, manufacturer, total, allocated)
Esempio n. 9
0
    def test_total_negative(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 'AMD'
        total = -100
        allocated = 41

        with self.assertRaises(ResourceError):
            r = Resource(name, manufacturer, total, allocated)
Esempio n. 10
0
    def test_name(self):
        name = 'Intel Core i9-9900'
        manufacturer = 'Intel'
        total = 41
        allocated = 40

        r = Resource(name, manufacturer, total, allocated)
        self.assertEqual(name, r.name)
Esempio n. 11
0
    def test_manufacturer_error(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 15554
        total = 41
        allocated = 41

        with self.assertRaises(ResourceError):
            r = Resource(name, manufacturer, total, allocated)
Esempio n. 12
0
    def test_name_error(self):
        name = 123
        manufacturer = 'Intel'
        total = 41
        allocated = 41

        with self.assertRaises(ResourceError):
            r = Resource(name, manufacturer, total, allocated)
Esempio n. 13
0
    def test_allocated(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 'AMD'
        total = 80
        allocated = 78

        r = Resource(name, manufacturer, total, allocated)
        self.assertEqual(allocated, r.allocated)
Esempio n. 14
0
    def test_total(self):
        name = 'Intel LGA1151 i7-9700K'
        manufacturer = 'Intel'
        total = 26
        allocated = 26

        r = Resource(name, manufacturer, total, allocated)
        self.assertEqual(total, r.total)
Esempio n. 15
0
    def test_category(self):
        name = 'AMD APU AM4 A6-9500'
        manufacturer = 'AMD'
        total = 50
        allocated = 41

        r = Resource(name, manufacturer, total, allocated)
        self.assertEqual(r.category, 'resource')
Esempio n. 16
0
    def test_manufacturer(self):
        name = 'Ryzen 3 1200'
        manufacturer = 'AMD'
        total = 34
        allocated = 34

        r = Resource(name, manufacturer, total, allocated)
        self.assertEqual(manufacturer, r.manufacturer)