예제 #1
0
 def test_update_data(self):
     """Test that row is updated."""
     generator = BandwidthGenerator(self.two_hours_ago, self.now,
                                    self.payer_account, self.usage_accounts)
     start_row = {}
     row = generator._update_data(start_row, self.two_hours_ago, self.now)
     self.assertIn(row["ConsumedService"], CONSUMED_SERVICE)
예제 #2
0
 def test_update_data(self):
     """Test that row is updated."""
     generator = BandwidthGenerator(self.two_hours_ago, self.now)
     start_row = {}
     row = generator._update_data(start_row,
                                  self.two_hours_ago,
                                  self.now,
                                  config=self.test_config_kwargs)
     self.assertIn(row["ConsumedService"], CONSUMED_SERVICE)
예제 #3
0
 def test_update_data(self):
     """Test that row is updated."""
     default_generators = [
         BandwidthGenerator(self.two_hours_ago, self.now, self.account_info, self.attributes),
         BandwidthGenerator(self.two_hours_ago, self.now, self.account_info, self.attributes_v2),
     ]
     for generator in default_generators:
         start_row = {}
         row = generator._update_data(start_row, self.two_hours_ago, self.now)
         self.assertIn(row["ConsumedService"], CONSUMED_SERVICE)
예제 #4
0
 def test_init_with_attributes(self):
     """Test the unique init options for Bandwidth."""
     default_generators = [
         BandwidthGenerator(self.two_hours_ago, self.now, self.account_info, self.attributes),
         BandwidthGenerator(self.two_hours_ago, self.now, self.account_info, self.attributes_v2),
     ]
     for generator in default_generators:
         self.assertEqual(generator._service_name, "Bandwidth")
         self.assertEqual(generator._meter_id, self.meter_id)
         self.assertEqual(generator._tags, self.tags)
         self.assertEqual(generator._usage_quantity, self.usage_quantity)
         self.assertEqual(generator._resource_rate, self.resource_rate)
         self.assertEqual(generator._pre_tax_cost, self.pre_tax_cost)
예제 #5
0
 def test_init_with_service_name_attribute(self):
     """Test the unique init options for Bandwidth."""
     self.attributes['service_name'] = 'whammy'
     generator = BandwidthGenerator(self.two_hours_ago, self.now,
                                    self.payer_account, self.usage_accounts,
                                    self.attributes)
     self.assertEqual(generator._service_name, 'whammy')
예제 #6
0
 def test_init_no_attributes(self):
     """Test the init wihout attributes."""
     generator = BandwidthGenerator(
         self.two_hours_ago, self.now, self.account_info, attributes={"empty": "dictionary"}
     )
     self.assertEqual(generator._service_name, "Bandwidth")
     self.assertIsNone(generator._service_tier)
예제 #7
0
 def test_init_no_attributes(self):
     """Test the init wihout attributes."""
     generator = BandwidthGenerator(self.two_hours_ago, self.now)
     self.assertIsNotNone(generator.config[0].get("instance_id"))
     self.assertIsNotNone(generator.config[0].get("meter_id"))
     self.assertIsNotNone(generator.config[0].get("resource_location"))
     self.assertIsNotNone(generator.config[0].get("resource_rate"))
     self.assertIsNotNone(generator.config[0].get("usage_quantity"))
예제 #8
0
 def test_init_no_attributes(self):
     """Test the init wihout attributes."""
     generator = BandwidthGenerator(self.two_hours_ago,
                                    self.now,
                                    self.payer_account,
                                    self.usage_accounts,
                                    attributes={'empty': 'dictionary'})
     self.assertEqual(generator._service_name, 'Bandwidth')
     self.assertIsNone(generator._service_tier)
예제 #9
0
 def test_init_with_attributes(self):
     """Test the unique init options for Bandwidth."""
     generator = BandwidthGenerator(self.two_hours_ago, self.now,
                                    self.payer_account, self.usage_accounts,
                                    self.attributes)
     self.assertEqual(generator._service_name, 'Bandwidth')
     self.assertEqual(generator._service_tier, self.service_tier)
     self.assertEqual(generator._meter_id, self.meter_id)
     self.assertEqual(generator._tags, self.tags)
     self.assertEqual(generator._usage_quantity, self.usage_quantity)
     self.assertEqual(generator._resource_rate, self.resource_rate)
     self.assertEqual(generator._pre_tax_cost, self.pre_tax_cost)
예제 #10
0
 def test_init_with_attributes(self):
     """Test the unique init options for Bandwidth."""
     test_args = self.test_config_kwargs
     test_args["generator"] = "BandwidthGenerator"
     test_config = create_test_config(**test_args)
     generator = BandwidthGenerator(self.two_hours_ago,
                                    self.now,
                                    user_config=test_config)
     self.assertEqual(generator.config[0].get("instance_id"),
                      self.instance_id)
     self.assertEqual(generator.config[0].get("meter_id"), self.meter_id)
     self.assertIn(self.tags["key"], generator.config[0].get("tags").keys())
     self.assertEqual(generator.config[0].get("usage_quantity"),
                      self.usage_quantity)
     self.assertEqual(generator.config[0].get("resource_rate"),
                      self.resource_rate)
     self.assertEqual(generator.config[0].get("pre_tax_cost"),
                      self.pre_tax_cost)
     os.remove(test_config)