Merge lp:~bac/charmworld/index-charms-in-bundles into lp:~juju-jitsu/charmworld/trunk

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: 368
Merged at revision: 368
Proposed branch: lp:~bac/charmworld/index-charms-in-bundles
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 82 lines (+33/-11)
2 files modified
charmworld/search.py (+1/-1)
charmworld/tests/test_search.py (+32/-10)
To merge this branch: bzr merge lp:~bac/charmworld/index-charms-in-bundles
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+182194@code.launchpad.net

Commit message

Allow elasticsearch to search for charm names within the services dict in a bundle.

Description of the change

Allow elasticsearch to search for charm names within the services dict in a bundle.

I took the opportunity to re-factor the indexing test so there is a single test for each thing being tested rather than one test that checks a bazillion things. The only new test is the last in the bunch.

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

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/search.py'
2--- charmworld/search.py 2013-08-23 20:22:19 +0000
3+++ charmworld/search.py 2013-08-26 19:45:33 +0000
4@@ -48,7 +48,7 @@
5 'basket': 5,
6 'description': 3,
7 'title': None,
8- 'data.services': None,
9+ 'data.services.*.charm': None,
10 }
11
12 CHARM = 'charm'
13
14=== modified file 'charmworld/tests/test_search.py'
15--- charmworld/tests/test_search.py 2013-08-23 21:51:41 +0000
16+++ charmworld/tests/test_search.py 2013-08-26 19:45:33 +0000
17@@ -149,9 +149,7 @@
18 self.assertEqual(1, len(results['bundle']))
19 self.assertEqual(bundle, results['bundle'][0]['data'])
20
21- def test_store_bundles(self):
22- # Ensure that bundles stored into the index via the `store_bundles`
23- # function are searchable via the index.
24+ def _setup_store_bundles(self):
25 _id = '~abentley/wordpress-basket/5/wordpress-stage'
26 deployer_config = dedent("""\
27 wordpress-stage:
28@@ -163,23 +161,47 @@
29 options:
30 tuning: optimized
31 engine: apache
32+ db:
33+ charm: cs:precise/mysql
34 """)
35 parsed = yaml.safe_load(deployer_config)
36- client = self.index_client
37 store_bundles(None, parsed, 'abentley', 'wordpress-basket/5',
38- index_client=client)
39+ index_client=self.index_client)
40+ return _id
41+
42+ def test_store_bundles_bundle_name_indexed(self):
43+ # Ensure that bundles stored into the index via the `store_bundles`
44+ # function are searchable via the index.
45+ _id = self._setup_store_bundles();
46+
47 # Bundle name is indexed.
48- results = client.search('wordpress-stage')['results']['bundle']
49+ results = self.index_client.search(
50+ 'wordpress-stage')['results']['bundle']
51 self.assertEqual(1, len(results))
52 self.assertEqual(_id, results[0]['data'].id)
53+
54+
55+ def test_store_bundles_series_indexed(self):
56+ _id = self._setup_store_bundles();
57 # Series is indexed.
58- results = client.search('precise')['results']['bundle']
59+ results = self.index_client.search('precise')['results']['bundle']
60 self.assertEqual(1, len(results))
61 self.assertEqual(_id, results[0]['data'].id)
62+
63+ def test_store_bundles_series_indexed(self):
64+ _id = self._setup_store_bundles();
65 # Owner is indexed.
66- results = client.search('abentley')['results']['bundle']
67- self.assertEqual(1, len(results))
68- self.assertEqual(_id, results[0]['data'].id)
69+ results = self.index_client.search('abentley')['results']['bundle']
70+ self.assertEqual(1, len(results))
71+ self.assertEqual(_id, results[0]['data'].id)
72+
73+ def test_store_bundles_series_indexed(self):
74+ _id = self._setup_store_bundles();
75+ # Charm names within services are index.
76+ results = self.index_client.search('mysql')['results']['bundle']
77+ self.assertEqual(1, len(results))
78+ self.assertEqual(_id, results[0]['data'].id)
79+
80
81 def test_search_charms_and_bundles_same_name(self):
82 charm = Charm(self.makeCharm(name='mozilla'))

Subscribers

People subscribed via source and target branches