Skip to content

Commit

Permalink
unit cov
Browse files Browse the repository at this point in the history
  • Loading branch information
lcouzens committed Aug 13, 2024
1 parent 37ca88f commit 2d3edce
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_aws_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,21 @@ def test_update_data(self):
self.assertEqual(row["product/productFamily"], "Data Transfer")
self.assertEqual(row[self.cost_category_key], self.cost_category_value)

def test_update_data_transfer_negation(self):
"""Test DataTransfer specific update data with negation costs."""
self.attributes = {
"rate": 20,
"amount": 1,
"negation": True,
}
generator = DataTransferGenerator(
self.two_hours_ago, self.now, self.currency, self.payer_account, self.usage_accounts, self.attributes
)
start_row = {}
row = generator._update_data(start_row, self.two_hours_ago, self.now)

self.assertEqual(row["lineItem/LineItemType"], "SavingsPlanNegation")


class TestEBSGenerator(AWSGeneratorTestCase):
"""Tests for the EBS Generator type."""
Expand Down Expand Up @@ -390,6 +405,20 @@ def test_init_with_attributes(self):
self.assertEqual(generator._resource_id, "i-" + self.resource_id)
self.assertEqual(generator._instance_type[:-1], tuple(self.instance_type.values()))

def test_update_data_ec2_negation(self):
"""Test EC2 specific update data with negation costs."""
self.instance_type = {
"negation": True,
}
self.attributes["instance_type"] = self.instance_type
generator = EC2Generator(
self.two_hours_ago, self.now, self.currency, self.payer_account, self.usage_accounts, self.attributes
)
start_row = {}
row = generator._update_data(start_row, self.two_hours_ago, self.now)

self.assertEqual(row["lineItem/LineItemType"], "SavingsPlanNegation")

def test_update_data(self):
"""Test EBS specific update data method."""
generator = EC2Generator(
Expand Down

0 comments on commit 2d3edce

Please sign in to comment.