Skip to content

Commit 97cb046

Browse files
Merge pull request #1765 from allmightyspiff/issues1764
Fixed maxint issue
2 parents 7a672a4 + 415c901 commit 97cb046

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ jobs:
4848
with:
4949
user: __token__
5050
password: ${{ secrets.CGALLO_PYPI }}
51-
repository_url: https://pypi.org/legacy/
51+
repository_url: https://upload.pypi.org/legacy/
5252

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: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
55
:license: MIT, see LICENSE for more details.
66
"""
7+
import datetime
78
import json
9+
from unittest import mock as mock
810

911
from SoftLayer.CLI import exceptions
1012
from SoftLayer import testing
@@ -21,27 +23,22 @@ def test_list_accounts(self):
2123
'domain': 'test.example.com',
2224
'origin': '1.1.1.1',
2325
'status': 'CNAME_CONFIGURATION',
24-
'unique_id': '9934111111111',
26+
'unique_id': '11223344',
2527
'vendor': 'akamai'}]
2628
)
2729

28-
def test_detail_account(self):
30+
@mock.patch('SoftLayer.utils.days_to_datetime')
31+
def test_detail_account(self, mock_now):
32+
mock_now.return_value = datetime.datetime(2020, 1, 1)
2933
result = self.run_command(['cdn', 'detail', '--history=30', '1245'])
3034

3135
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-
)
36+
api_results = json.loads(result.output)
37+
self.assertEqual(api_results['hit_ratio'], '2.0 %')
38+
self.assertEqual(api_results['total_bandwidth'], '1.0 GB')
39+
self.assertEqual(api_results['total_hits'], 3)
40+
self.assertEqual(api_results['hostname'], 'test.example.com')
41+
self.assertEqual(api_results['protocol'], 'HTTP')
4542

4643
def test_purge_content(self):
4744
result = self.run_command(['cdn', 'purge', '1234',
@@ -122,7 +119,7 @@ def test_edit_cache(self):
122119
self.assertEqual('include: test', header_result['Cache key optimization'])
123120

124121
def test_edit_cache_by_uniqueId(self):
125-
result = self.run_command(['cdn', 'edit', '9934111111111', '--cache', 'include-specified', '--cache', 'test'])
122+
result = self.run_command(['cdn', 'edit', '11223344', '--cache', 'include-specified', '--cache', 'test'])
126123
self.assert_no_fail(result)
127124
header_result = json.loads(result.output)
128125
self.assertEqual('include: test', header_result['Cache key optimization'])

tests/managers/cdn_tests.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
55
:license: MIT, see LICENSE for more details.
66
"""
7+
import datetime
8+
from unittest import mock as mock
79

810
from SoftLayer import fixtures
911
from SoftLayer.managers import cdn
@@ -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,15 @@ 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+
4255
def test_get_origins(self):
4356
self.cdn_client.get_origins("12345")
4457
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping_Path',
@@ -105,7 +118,7 @@ def test_purge_content(self):
105118
args=args)
106119

107120
def test_cdn_edit(self):
108-
identifier = '9934111111111'
121+
identifier = '11223344'
109122
header = 'www.test.com'
110123
result = self.cdn_client.edit(identifier, header=header)
111124

@@ -116,7 +129,7 @@ def test_cdn_edit(self):
116129
'SoftLayer_Network_CdnMarketplace_Configuration_Mapping',
117130
'updateDomainMapping',
118131
args=({
119-
'uniqueId': '9934111111111',
132+
'uniqueId': '11223344',
120133
'originType': 'HOST_SERVER',
121134
'protocol': 'HTTP',
122135
'path': '/',

0 commit comments

Comments
 (0)