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)
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)
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)
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__())
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)
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)
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)
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)
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)
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)
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)
def test_name_error(self): name = 123 manufacturer = 'Intel' total = 41 allocated = 41 with self.assertRaises(ResourceError): r = Resource(name, manufacturer, total, allocated)
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)
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)
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')
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)