Merge lp:~abentley/charmworld/factory-uses-process-charm into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Curtis Hovey
Approved revision: 258
Merged at revision: 258
Proposed branch: lp:~abentley/charmworld/factory-uses-process-charm
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 176 lines (+21/-24)
3 files modified
charmworld/jobs/ingest.py (+4/-3)
charmworld/testing/factory.py (+2/-6)
charmworld/views/tests/test_helpers.py (+15/-15)
To merge this branch: bzr merge lp:~abentley/charmworld/factory-uses-process-charm
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+168724@code.launchpad.net

Commit message

Update factory to use ScanJob.process_charm.

Description of the change

This branch updates factory.get_charm_json to use ScanJob.process_charm.

This makes the output of factory.get_charm_json more realistic, and also ensures that future updates to process_charm will update get_charm_json appropriately.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you for cleaning this up.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/jobs/ingest.py'
2--- charmworld/jobs/ingest.py 2013-06-07 12:36:30 +0000
3+++ charmworld/jobs/ingest.py 2013-06-11 16:15:57 +0000
4@@ -521,7 +521,8 @@
5 if isinstance(relation_data, StringTypes):
6 interfaces[relation_name] = {'interface': relation_data}
7
8- def process_charm(self, charm):
9+ @classmethod
10+ def process_charm(cls, charm):
11 # Enrich charm metadata for webapp.
12
13 # Charm url
14@@ -545,7 +546,7 @@
15 i_provides = []
16 provides = charm.get("provides")
17 if provides:
18- self.normalize_interfaces(provides)
19+ cls.normalize_interfaces(provides)
20 for v in provides.values():
21 if not isinstance(v, dict):
22 continue
23@@ -559,7 +560,7 @@
24 i_requires = []
25 requires = charm.get("requires")
26 if requires:
27- self.normalize_interfaces(requires)
28+ cls.normalize_interfaces(requires)
29 for v in requires.values():
30 i = v.get("interface")
31 if not i:
32
33=== modified file 'charmworld/testing/factory.py'
34--- charmworld/testing/factory.py 2013-06-07 12:36:30 +0000
35+++ charmworld/testing/factory.py 2013-06-11 16:15:57 +0000
36@@ -21,6 +21,7 @@
37 )
38 from charmworld.jobs.ingest import (
39 JENKINS_PROVIDERS,
40+ ScanIngestJob,
41 )
42 from charmworld.models import (
43 getfs,
44@@ -208,12 +209,7 @@
45 "stop",
46 "website-relation-joined"
47 ],
48- "i_provides": [relation['interface']
49- for relation in provides.values()],
50- "i_requires": [relation['interface']
51- for relation in requires.values()],
52 'is_featured': is_featured,
53- "label": "precise/byobu-classroom",
54 "last_change": {
55 "committer": "John Doe <jdoe@example.com>",
56 "created": 1343082725.06,
57@@ -234,7 +230,6 @@
58 'requires': requires,
59 "revision": revision,
60 "series": series,
61- "short_url": "/charms/precise/byobu-classroom",
62 "summary": summary,
63 'config': {
64 'options': options,
65@@ -267,6 +262,7 @@
66 charm['name'], charm['branch_spec'], status, provider)
67 if subordinate:
68 charm['subordinate'] = True
69+ ScanIngestJob.process_charm(charm)
70 return charm
71
72
73
74=== modified file 'charmworld/views/tests/test_helpers.py'
75--- charmworld/views/tests/test_helpers.py 2013-05-21 12:41:57 +0000
76+++ charmworld/views/tests/test_helpers.py 2013-06-11 16:15:57 +0000
77@@ -30,10 +30,10 @@
78 '_id': '~charmers/charms/precise/some_webapp/trunk',
79 'i_provides': ['http'],
80 'i_requires': ['pgsql'],
81- 'label': 'precise/byobu-classroom',
82+ 'label': 'precise/some_webapp',
83 'name': 'some_webapp',
84 'owner': 'charmers',
85- 'short_url': '/charms/precise/byobu-classroom',
86+ 'short_url': '/charms/precise/some_webapp',
87 'store_url': 'cs:precise/some_webapp-1',
88 },
89 ],
90@@ -46,10 +46,10 @@
91 '_id': '~charmers/charms/precise/some_dbserver/trunk',
92 'i_provides': ['pgsql'],
93 'i_requires': [],
94- 'label': 'precise/byobu-classroom',
95+ 'label': 'precise/some_dbserver',
96 'name': 'some_dbserver',
97 'owner': 'charmers',
98- 'short_url': '/charms/precise/byobu-classroom',
99+ 'short_url': '/charms/precise/some_dbserver',
100 'store_url': 'cs:precise/some_dbserver-1',
101 },
102 ],
103@@ -58,10 +58,10 @@
104 '_id': '~charmers/charms/precise/some_webapp/trunk',
105 'i_provides': ['http'],
106 'i_requires': ['pgsql'],
107- 'label': 'precise/byobu-classroom',
108+ 'label': 'precise/some_webapp',
109 'name': 'some_webapp',
110 'owner': 'charmers',
111- 'short_url': '/charms/precise/byobu-classroom',
112+ 'short_url': '/charms/precise/some_webapp',
113 'store_url': 'cs:precise/some_webapp-1',
114 }
115 ],
116@@ -92,10 +92,10 @@
117 '_id': '~charmers/charms/precise/some_webapp/trunk',
118 'i_provides': ['http'],
119 'i_requires': ['pgsql'],
120- 'label': 'precise/byobu-classroom',
121+ 'label': 'precise/some_webapp',
122 'name': 'some_webapp',
123 'owner': 'charmers',
124- 'short_url': '/charms/precise/byobu-classroom',
125+ 'short_url': '/charms/precise/some_webapp',
126 'store_url': 'cs:precise/some_webapp-1',
127 },
128 ],
129@@ -109,10 +109,10 @@
130 '_id': '~charmers/charms/precise/some_webapp/trunk',
131 'i_provides': ['http'],
132 'i_requires': ['pgsql'],
133- 'label': 'precise/byobu-classroom',
134+ 'label': 'precise/some_webapp',
135 'name': 'some_webapp',
136 'owner': 'charmers',
137- 'short_url': '/charms/precise/byobu-classroom',
138+ 'short_url': '/charms/precise/some_webapp',
139 'store_url': 'cs:precise/some_webapp-1',
140 }
141 ],
142@@ -121,7 +121,7 @@
143 self.assertEqual(expected, result)
144
145 def test_interfaces_unreviewed_charm(self):
146- # Unreveiwed charms are only returned if no reviewed charm
147+ # Unreviewed charms are only returned if no reviewed charm
148 # with the same name exists.
149 one_id, one = factory.makeCharm(
150 self.db, name='some_dbserver', owner='foo',
151@@ -135,10 +135,10 @@
152 '_id': '~foo/charms/precise/some_dbserver/trunk',
153 'i_provides': ['pgsql'],
154 'i_requires': [],
155- 'label': 'precise/byobu-classroom',
156+ 'label': '~foo:precise/some_dbserver',
157 'name': 'some_dbserver',
158 'owner': 'foo',
159- 'short_url': '/charms/precise/byobu-classroom',
160+ 'short_url': '/~foo/precise/some_dbserver',
161 'store_url': 'cs:~foo/precise/some_dbserver-1',
162 },
163 ],
164@@ -162,10 +162,10 @@
165 '_id': '~charmers/charms/precise/some_dbserver/trunk',
166 'i_provides': ['pgsql'],
167 'i_requires': [],
168- 'label': 'precise/byobu-classroom',
169+ 'label': 'precise/some_dbserver',
170 'name': 'some_dbserver',
171 'owner': 'charmers',
172- 'short_url': '/charms/precise/byobu-classroom',
173+ 'short_url': '/charms/precise/some_dbserver',
174 'store_url': 'cs:precise/some_dbserver-1',
175 },
176 ],

Subscribers

People subscribed via source and target branches