def test_deprecated_device_with_components_in_venture(self): before_deprecated = get_device_price(self.srv1) self.assertEqual(before_deprecated, 2640) self.srv1.purchase_date = datetime.datetime(1999, 1, 1, 0, 0) self.srv1.save() dev = Device.objects.get(sn='srv-1') self.assertEqual( dev.deprecation_date, datetime.datetime(2001, 1, 1, 0, 0) ) after_deprecated = get_device_price(dev) self.assertEqual(after_deprecated, 0) venture = Venture.objects.get(name='Infra') url = '/ui/reports/device_prices_per_venture/?venture=%s' % venture.id response = self.client.get(url) self.assertEqual(response.status_code, 200) devices = response.context_data.get('rows') devices_list = response.context_data.get('rows') devices = devices_list.pop() for dev in devices.get('components', []): total = 0 for component in dev.get('components', []): total += component.get('price') self.assertEqual(dev.get('price'), total)
def test_deprecated_device_with_components_in_venture(self): before_deprecated = get_device_price(self.srv1) self.assertEqual(before_deprecated, 2640) self.srv1.purchase_date = datetime.datetime(1999, 1, 1, 0, 0) self.srv1.save() dev = Device.objects.get(sn='srv-1') self.assertEqual( dev.deprecation_date, datetime.datetime(2001, 1, 1, 0, 0) ) after_deprecated = get_device_price(dev) self.assertEqual(after_deprecated, 0) venture = Venture.objects.get(name='Infra') url = '/ui/reports/device_prices_per_venture/?venture=%s' % venture.id response = self.client.get(url) self.assertEqual(response.status_code, 200) devices = response.context_data.get('rows') for dev in devices: count, price, total_component, sum_dev = sum_for_view(dev) self.assertEqual(count * price, total_component) self.assertEqual(dev.get('price'), sum_dev) if dev.get('device').name == 'srv-1': self.assertEqual(sum_dev, 2640)
def test_deprecated_device_with_components_in_venture(self): before_deprecated = get_device_price(self.srv1) self.assertEqual(before_deprecated, 2640) self.srv1.purchase_date = datetime.datetime(1999, 1, 1, 0, 0) self.srv1.save() dev = Device.objects.get(sn='srv-1') self.assertEqual(dev.deprecation_date, datetime.datetime(2001, 1, 1, 0, 0)) after_deprecated = get_device_price(dev) self.assertEqual(after_deprecated, 0) venture = Venture.objects.get(name='Infra') url = '/ui/reports/device_prices_per_venture/?venture=%s' % venture.id response = self.client.get(url) self.assertEqual(response.status_code, 200) devices = response.context_data.get('rows') devices_list = response.context_data.get('rows') devices = devices_list.pop() for dev in devices.get('components', []): total = 0 for component in dev.get('components', []): total += component.get('price') self.assertEqual(dev.get('price'), total)