Skip to content

Commit 7c414fd

Browse files
#1764 lowered a value in the unit tests below max 32bit int
1 parent 4bad4e6 commit 7c414fd

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

SoftLayer/CLI/cdn/detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def cli(env, unique_id, history):
4141
table.add_row(['status', cdn_mapping['status']])
4242
table.add_row(['total_bandwidth', total_bandwidth])
4343
table.add_row(['total_hits', total_hits])
44-
table.add_row(['hit_radio', hit_ratio])
44+
table.add_row(['hit_ratio', hit_ratio])
4545

4646
env.fout(table)

SoftLayer/fixtures/SoftLayer_Network_CdnMarketplace_Configuration_Mapping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"path": "/",
1212
"protocol": "HTTP",
1313
"status": "CNAME_CONFIGURATION",
14-
"uniqueId": "9934111111111",
14+
"uniqueId": "11223344",
1515
"vendorName": "akamai"
1616
}
1717
]
@@ -28,7 +28,7 @@
2828
"path": "/",
2929
"protocol": "HTTP",
3030
"status": "CNAME_CONFIGURATION",
31-
"uniqueId": "9934111111111",
31+
"uniqueId": "11223344",
3232
"vendorName": "akamai"
3333
}
3434
]
@@ -41,7 +41,7 @@
4141
"performanceConfiguration": "Large file optimization",
4242
"protocol": "HTTP",
4343
"respectHeaders": True,
44-
"uniqueId": "424406419091111",
44+
"uniqueId": "11223344",
4545
"vendorName": "akamai",
4646
"header": "www.test.com",
4747
"httpPort": 83,

SoftLayer/fixtures/SoftLayer_Network_CdnMarketplace_Metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"HitRatio"
77
],
88
"totals": [
9-
"0.0",
10-
"0",
11-
"0.0"
9+
1.0,
10+
3,
11+
2.0
1212
],
1313
"type": "TOTALS"
1414
}

tests/CLI/modules/cdn_tests.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,20 @@ def test_list_accounts(self):
2121
'domain': 'test.example.com',
2222
'origin': '1.1.1.1',
2323
'status': 'CNAME_CONFIGURATION',
24-
'unique_id': '9934111111111',
24+
'unique_id': '11223344',
2525
'vendor': 'akamai'}]
2626
)
2727

2828
def test_detail_account(self):
2929
result = self.run_command(['cdn', 'detail', '--history=30', '1245'])
3030

3131
self.assert_no_fail(result)
32-
self.assertEqual(json.loads(result.output),
33-
{'hit_radio': '0.0 %',
34-
'hostname': 'test.example.com',
35-
'origin': '1.1.1.1',
36-
'origin_type': 'HOST_SERVER',
37-
'path': '/',
38-
'protocol': 'HTTP',
39-
'provider': 'akamai',
40-
'status': 'CNAME_CONFIGURATION',
41-
'total_bandwidth': '0.0 GB',
42-
'total_hits': '0',
43-
'unique_id': '9934111111111'}
44-
)
32+
api_results = json.loads(result.output)
33+
self.assertEqual(api_results['hit_ratio'], '2.0 %')
34+
self.assertEqual(api_results['total_bandwidth'], '1.0 GB')
35+
self.assertEqual(api_results['total_hits'], 3)
36+
self.assertEqual(api_results['hostname'], 'test.example.com')
37+
self.assertEqual(api_results['protocol'], 'HTTP')
4538

4639
def test_purge_content(self):
4740
result = self.run_command(['cdn', 'purge', '1234',
@@ -122,7 +115,7 @@ def test_edit_cache(self):
122115
self.assertEqual('include: test', header_result['Cache key optimization'])
123116

124117
def test_edit_cache_by_uniqueId(self):
125-
result = self.run_command(['cdn', 'edit', '9934111111111', '--cache', 'include-specified', '--cache', 'test'])
118+
result = self.run_command(['cdn', 'edit', '11223344', '--cache', 'include-specified', '--cache', 'test'])
126119
self.assert_no_fail(result)
127120
header_result = json.loads(result.output)
128121
self.assertEqual('include: test', header_result['Cache key optimization'])

tests/managers/cdn_tests.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from SoftLayer import fixtures
99
from SoftLayer.managers import cdn
1010
from SoftLayer import testing
11+
from unittest import mock as mock
12+
import datetime
1113

1214

1315
class CDNTests(testing.TestCase):
@@ -28,7 +30,9 @@ def test_detail_cdn(self):
2830
'listDomainMappingByUniqueId',
2931
args=args)
3032

31-
def test_detail_usage_metric(self):
33+
@mock.patch('SoftLayer.utils.days_to_datetime')
34+
def test_detail_usage_metric(self, mock_now):
35+
mock_now.return_value = datetime.datetime(2020, 1, 1)
3236
self.cdn_client.get_usage_metrics(12345, history=30, frequency="aggregate")
3337

3438
args = (12345,
@@ -39,6 +43,16 @@ def test_detail_usage_metric(self):
3943
'getMappingUsageMetrics',
4044
args=args)
4145

46+
# Does this still work in 2038 ? https://github.com/softlayer/softlayer-python/issues/1764 for context
47+
@mock.patch('SoftLayer.utils.days_to_datetime')
48+
def test_detail_usage_metric_future(self, mock_now):
49+
mock_now.return_value = datetime.datetime(2040, 1, 1)
50+
self.assertRaises(
51+
OverflowError,
52+
self.cdn_client.get_usage_metrics, 12345, history=30, frequency="aggregate"
53+
)
54+
55+
4256
def test_get_origins(self):
4357
self.cdn_client.get_origins("12345")
4458
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping_Path',
@@ -105,7 +119,7 @@ def test_purge_content(self):
105119
args=args)
106120

107121
def test_cdn_edit(self):
108-
identifier = '9934111111111'
122+
identifier = '11223344'
109123
header = 'www.test.com'
110124
result = self.cdn_client.edit(identifier, header=header)
111125

@@ -116,7 +130,7 @@ def test_cdn_edit(self):
116130
'SoftLayer_Network_CdnMarketplace_Configuration_Mapping',
117131
'updateDomainMapping',
118132
args=({
119-
'uniqueId': '9934111111111',
133+
'uniqueId': '11223344',
120134
'originType': 'HOST_SERVER',
121135
'protocol': 'HTTP',
122136
'path': '/',

0 commit comments

Comments
 (0)