Merge lp:~nskaggs/juju-ci-tools/fix-1589645 into lp:juju-ci-tools

Proposed by Nicholas Skaggs
Status: Merged
Merged at revision: 1463
Proposed branch: lp:~nskaggs/juju-ci-tools/fix-1589645
Merge into: lp:juju-ci-tools
Diff against target: 66 lines (+16/-7)
2 files modified
assess_resources.py (+8/-3)
tests/test_assess_resources.py (+8/-4)
To merge this branch: bzr merge lp:~nskaggs/juju-ci-tools/fix-1589645
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+296681@code.launchpad.net

Description of the change

functional-resources needs to support applicationid

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

This breaks compatibility with beta8 and earlier. Please support both "serviceid" and "applicationId".

review: Needs Fixing
1458. By Nicholas Skaggs

support serviceid too

Revision history for this message
Aaron Bentley (abentley) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assess_resources.py'
2--- assess_resources.py 2016-05-24 22:42:10 +0000
3+++ assess_resources.py 2016-06-07 20:11:00 +0000
4@@ -23,10 +23,10 @@
5 log = logging.getLogger("assess_resources")
6
7
8-def _resource_info(name, fingerprint, size):
9+def _resource_info(name, fingerprint, size, service_app_id):
10 data = {}
11 data['resourceid'] = "dummy-resource/{}".format(name)
12- data['serviceid'] = 'dummy-resource'
13+ data[service_app_id] = 'dummy-resource'
14 data['name'] = name
15 data['type'] = 'file'
16 data['description'] = '{} resource.'.format(name)
17@@ -43,7 +43,12 @@
18 resources = status['resources']
19 for resource in resources:
20 if resource['expected']['resourceid'] == resource_id:
21- expected_values = _resource_info(name, fingerprint, size)
22+ if 'serviceid' in resource['unit']:
23+ service_app_id = 'serviceid'
24+ else:
25+ service_app_id = 'applicationId'
26+ expected_values = _resource_info(name, fingerprint,
27+ size, service_app_id)
28 if resource['expected'] != expected_values:
29 raise JujuAssertionError(
30 'Unexpected resource list values: {} Expected: {}'.format(
31
32=== modified file 'tests/test_assess_resources.py'
33--- tests/test_assess_resources.py 2016-05-24 22:42:10 +0000
34+++ tests/test_assess_resources.py 2016-06-07 20:11:00 +0000
35@@ -67,6 +67,10 @@
36 verify_status(
37 make_resource_list(), 'dummy-resource/foo', 'foo', '1234', 27)
38
39+ def test_verify_status_serviceid(self):
40+ verify_status(make_resource_list('serviceid'), 'dummy-resource/foo',
41+ 'foo', '1234', 27)
42+
43 def test_verify_status_exception(self):
44 status = make_resource_list()
45 status['resources'][0]['expected']['origin'] = 'charmstore'
46@@ -213,17 +217,17 @@
47 temp_env_name='an-env-mod', upload_tools=False, verbose=10)
48
49
50-def make_resource_list():
51+def make_resource_list(service_app_id='applicationId'):
52 return {'resources': [{
53 'expected': {
54 'origin': 'upload', 'used': True, 'description': 'foo resource.',
55 'username': 'admin@local', 'resourceid': 'dummy-resource/foo',
56- 'name': 'foo', 'serviceid': 'dummy-resource', 'path': 'foo.txt',
57- 'fingerprint': '1234', 'type': 'file', 'size': 27},
58+ 'name': 'foo', service_app_id: 'dummy-resource', 'size': 27,
59+ 'fingerprint': '1234', 'type': 'file', 'path': 'foo.txt'},
60 'unit': {
61 'origin': 'upload', 'username': 'admin@local', 'used': True,
62 'name': 'foo', 'resourceid': 'dummy-resource/foo',
63- 'serviceid': 'dummy-resource', 'fingerprint': '1234',
64+ service_app_id: 'dummy-resource', 'fingerprint': '1234',
65 'path': 'foo.txt', 'size': 27, 'type': 'file',
66 'description': 'foo resource.'}}]}
67

Subscribers

People subscribed via source and target branches