예제 #1
0
 def test_fail_plugin(self):
     """ Testing not configured plugin """
     with mock.patch(
             'ralph_pricing.plugins.collects.hamster.get_venture_capacity'
     ) as get_venture_capacity:
         get_venture_capacity.side_effect = mock_get_venture_capacity
         status, message, args = hamster_runner(
             today=datetime.datetime.today())
         self.assertFalse(status)
예제 #2
0
    def test_set_usages(self):
        """ Hamster usages Test Case """
        # fake setting need to run plugin
        settings.HAMSTER_API_URL = "/"
        with mock.patch(
                'ralph_pricing.plugins.collects.hamster.get_venture_capacity'
        ) as get_venture_capacity:
            get_venture_capacity.side_effect = mock_get_venture_capacity
            status, message, args = hamster_runner(
                today=datetime.datetime.today())
            self.assertTrue(status)

            usages = DailyUsage.objects.all()
            self.assertEqual(len(usages), 2)

            usage_venture1 = DailyUsage.objects.get(
                pricing_venture=self.venture_1)
            usage_venture2 = DailyUsage.objects.get(
                pricing_venture=self.venture_2)
            self.assertEqual(usage_venture1.value,
                             2131231233.0 / (1024 * 1024))
            self.assertEqual(usage_venture2.value,
                             4234233423.0 / (1024 * 1024))