Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 def test_view_devices_with_components_in_venture(self):
     ''' Tests device with local components, with praces from catalog '''
     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)