コード例 #1
0
ファイル: test_scaleme.py プロジェクト: xliiv/ralph_pricing
 def test_fail_plugin(self):
     """Testing not configured plugin"""
     with mock.patch(
             'ralph_pricing.plugins.collects.scaleme.get_ventures_capacities'
     ) as get_ventures_capacities:
         get_ventures_capacities.side_effect = mock_get_ventures_capacities
         status, message, args = scaleme_runner(
             today=datetime.datetime.today(), )
         self.assertFalse(status)
コード例 #2
0
ファイル: test_scaleme.py プロジェクト: ar4s/ralph_pricing
 def test_fail_plugin(self):
     """Testing not configured plugin"""
     with mock.patch(
         'ralph_pricing.plugins.collects.scaleme.get_ventures_capacities'
     ) as get_ventures_capacities:
         get_ventures_capacities.side_effect = mock_get_ventures_capacities
         status, message, args = scaleme_runner(
             today=datetime.datetime.today(),
         )
         self.assertFalse(status)
コード例 #3
0
ファイル: test_scaleme.py プロジェクト: ar4s/ralph_pricing
    def test_set_usages(self):
        """Scaleme usages Test Case"""
        settings.SCALEME_API_URL = "/"
        with mock.patch(
            'ralph_pricing.plugins.collects.scaleme.get_ventures_capacities'
        ) as get_ventures_capacities:
            get_ventures_capacities.side_effect = mock_get_ventures_capacities
            status, message, args = scaleme_runner(
                today=datetime.datetime.today()
            )
            self.assertTrue(status)
            usages = DailyUsage.objects.all()
            self.assertEqual(usages.count(), 4)

            usage_backend = UsageType.objects.get(
                name='Scaleme transforming an image 10000 events',
            )
            usage_cache = UsageType.objects.get(
                name='Scaleme serving image from cache 10000 events',
            )

            usages_venture1 = DailyUsage.objects.filter(
                pricing_venture=self.venture_1,
            )
            usages_venture2 = DailyUsage.objects.filter(
                pricing_venture=self.venture_2,
            )
            usages_venture3 = DailyUsage.objects.filter(
                pricing_venture=self.venture_3,
            )

            self.assertEqual(usages_venture1.count(), 2)
            usage_backend_venture1 = usages_venture1.filter(type=usage_backend)
            usage_cache_venture1 = usages_venture1.filter(type=usage_cache)
            self.assertEqual(usage_backend_venture1[0].value, 987987)
            self.assertEqual(usage_cache_venture1[0].value, 7878)

            self.assertEqual(usages_venture2.count(), 2)
            usage_backend_venture2 = usages_venture2.filter(type=usage_backend)
            usage_cache_venture2 = usages_venture2.filter(type=usage_cache)
            self.assertEqual(usage_backend_venture2[0].value, 12346699)
            self.assertEqual(usage_cache_venture2[0].value, 666999)

            self.assertEqual(usages_venture3.count(), 0)
コード例 #4
0
ファイル: test_scaleme.py プロジェクト: xliiv/ralph_pricing
    def test_set_usages(self):
        """Scaleme usages Test Case"""
        settings.SCALEME_API_URL = "/"
        with mock.patch(
                'ralph_pricing.plugins.collects.scaleme.get_ventures_capacities'
        ) as get_ventures_capacities:
            get_ventures_capacities.side_effect = mock_get_ventures_capacities
            status, message, args = scaleme_runner(
                today=datetime.datetime.today())
            self.assertTrue(status)
            usages = DailyUsage.objects.all()
            self.assertEqual(usages.count(), 4)

            usage_backend = UsageType.objects.get(
                name='Scaleme transforming an image 10000 events', )
            usage_cache = UsageType.objects.get(
                name='Scaleme serving image from cache 10000 events', )

            usages_venture1 = DailyUsage.objects.filter(
                pricing_venture=self.venture_1, )
            usages_venture2 = DailyUsage.objects.filter(
                pricing_venture=self.venture_2, )
            usages_venture3 = DailyUsage.objects.filter(
                pricing_venture=self.venture_3, )

            self.assertEqual(usages_venture1.count(), 2)
            usage_backend_venture1 = usages_venture1.filter(type=usage_backend)
            usage_cache_venture1 = usages_venture1.filter(type=usage_cache)
            self.assertEqual(usage_backend_venture1[0].value, 987987)
            self.assertEqual(usage_cache_venture1[0].value, 7878)

            self.assertEqual(usages_venture2.count(), 2)
            usage_backend_venture2 = usages_venture2.filter(type=usage_backend)
            usage_cache_venture2 = usages_venture2.filter(type=usage_cache)
            self.assertEqual(usage_backend_venture2[0].value, 12346699)
            self.assertEqual(usage_cache_venture2[0].value, 666999)

            self.assertEqual(usages_venture3.count(), 0)