fixing tests that were broken due to unit conversions changes
Had to unify test case units. Will then also ideally want tests to ensure converters work as intended. Change-Id: I72b67881233b65955e56c023cdc0453b01919e56
This commit is contained in:
parent
5913740778
commit
0744926112
@ -1,10 +1,10 @@
|
||||
region | service0 | hour | 0.32
|
||||
region | service0 | gigabyte | 0.32
|
||||
region | service1 | gigabyte | 0.312
|
||||
region | service2 | hour | 0.43
|
||||
region | service2 | gigabyte | 0.43
|
||||
region | service3 | gigabyte | 0.38
|
||||
region | service4 | hour | 0.43
|
||||
region | service4 | gigabyte | 0.43
|
||||
region | service5 | gigabyte | 0.32
|
||||
region | service6 | hour | 0.312
|
||||
region | service6 | gigabyte | 0.312
|
||||
region | service7 | gigabyte | 0.53
|
||||
region | service8 | hour | 0.73
|
||||
region | service8 | gigabyte | 0.73
|
||||
region | service9 | gigabyte | 0.9
|
|
@ -22,6 +22,7 @@ def fill_db(session, numb_tenants, numb_resources, now):
|
||||
session.add(models.UsageEntry(
|
||||
service="service" + str(ii),
|
||||
volume=5,
|
||||
unit='gigabyte',
|
||||
resource_id="resource_id_" + str(ii),
|
||||
tenant_id="tenant_id_" + str(i),
|
||||
start=(now - timedelta(days=20)),
|
||||
|
@ -74,9 +74,6 @@ class TestApi(test_interface.TestInterface):
|
||||
|
||||
helpers.fill_db(self.session, numTenants, numResources, now)
|
||||
|
||||
for entry in self.session.query(models.UsageEntry):
|
||||
print entry
|
||||
|
||||
for i in range(numTenants):
|
||||
resp = self.app.post("/sales_order",
|
||||
params=json.dumps({"tenant": "tenant_id_" +
|
||||
@ -177,21 +174,25 @@ class TestApi(test_interface.TestInterface):
|
||||
'resources': {
|
||||
'resouce_ID_1': {
|
||||
'services': [{'name': 'service_1',
|
||||
'volume': Decimal(volume)},
|
||||
'volume': Decimal(volume),
|
||||
'unit': 'second'},
|
||||
{'name': 'service_2',
|
||||
'volume': Decimal(volume)}]
|
||||
'volume': Decimal(volume),
|
||||
'unit': 'second'}]
|
||||
},
|
||||
'resouce_ID_2': {
|
||||
'services': [{'name': 'service_1',
|
||||
'volume': Decimal(volume)},
|
||||
'volume': Decimal(volume),
|
||||
'unit': 'second'},
|
||||
{'name': 'service_2',
|
||||
'volume': Decimal(volume)}]
|
||||
'volume': Decimal(volume),
|
||||
'unit': 'second'}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
service_cost = round(convert_to(volume, rate['unit']) * rate['rate'],
|
||||
2)
|
||||
service_cost = round(
|
||||
convert_to(volume, 'second', rate['unit']) * rate['rate'], 2)
|
||||
total_cost = service_cost * 4
|
||||
|
||||
ratesManager = mock.MagicMock()
|
||||
@ -204,7 +205,8 @@ class TestApi(test_interface.TestInterface):
|
||||
self.assertEquals(resource['total_cost'], str(service_cost * 2))
|
||||
for service in resource['services']:
|
||||
self.assertEquals(service['volume'],
|
||||
str(convert_to(volume, rate['unit'])))
|
||||
str(convert_to(volume, 'second',
|
||||
rate['unit'])))
|
||||
self.assertEquals(service['unit'], rate['unit'])
|
||||
self.assertEquals(service['cost'], str(service_cost))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user