Merge lp:~tycho-s/simplestreams/fix-condense into lp:~smoser/simplestreams/trunk

Proposed by Tycho Andersen
Status: Merged
Merged at revision: 348
Proposed branch: lp:~tycho-s/simplestreams/fix-condense
Merge into: lp:~smoser/simplestreams/trunk
Diff against target: 80 lines (+19/-9)
2 files modified
simplestreams/util.py (+4/-3)
tests/unittests/test_util.py (+15/-6)
To merge this branch: bzr merge lp:~tycho-s/simplestreams/fix-condense
Reviewer Review Type Date Requested Status
Scott Moser Pending
Review via email: mp+222564@code.launchpad.net

Commit message

A few fixes to condense:

* hoist unicode stuff correctly
* hoist tags out of versions into being siblings of products

Description of the change

A few fixes to condense:

* hoist unicode stuff correctly
* hoist tags out of versions into being siblings of products

To post a comment you must log in.
348. By Tycho Andersen

whoops, don't commit pprint

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'simplestreams/util.py'
2--- simplestreams/util.py 2014-03-25 22:10:17 +0000
3+++ simplestreams/util.py 2014-06-09 21:20:41 +0000
4@@ -190,7 +190,7 @@
5 if not ref:
6 continue
7 value = data.get(key)
8- if value and isinstance(value, str):
9+ if value and isinstance(value, _STRING_TYPES):
10 data.update(ref[value])
11 if delete:
12 del data[key]
13@@ -370,11 +370,11 @@
14 if k not in candidates:
15 continue
16 if k in updates:
17- if v != updates[k] or not isinstance(v, str):
18+ if v != updates[k] or not isinstance(v, _STRING_TYPES):
19 del updates[k]
20 candidates.remove(k)
21 else:
22- if isinstance(v, str) and target.get(k, v) == v:
23+ if isinstance(v, _STRING_TYPES) and target.get(k, v) == v:
24 updates[k] = v
25 else:
26 candidates.remove(k)
27@@ -397,6 +397,7 @@
28
29 walk_products(ptree, cb_version=call_move_dups)
30 walk_products(ptree, cb_product=call_move_dups)
31+ move_dups(ptree['products'], ptree)
32
33
34 def assert_safe_path(path):
35
36=== modified file 'tests/unittests/test_util.py'
37--- tests/unittests/test_util.py 2014-03-25 14:12:01 +0000
38+++ tests/unittests/test_util.py 2014-06-09 21:20:41 +0000
39@@ -143,8 +143,17 @@
40 def test_condense_1(self):
41 tree = {'products': {'P1': {'versions': {'1': {'A': 'B'},
42 '2': {'A': 'B'}}}}}
43- exp = {'products': {'P1': {'versions': {'1': {}, '2': {}},
44- 'A': 'B'}}}
45+ exp = {'A': 'B',
46+ 'products': {'P1': {'versions': {'1': {}, '2': {}}}}}
47+
48+ util.products_condense(tree)
49+ self.assertEqual(tree, exp)
50+
51+ def test_condense_unicode(self):
52+ tree = {'products': {'P1': {'versions': {'1': {'A': u'B'},
53+ '2': {'A': u'B'}}}}}
54+ exp = {'A': u'B',
55+ 'products': {'P1': {'versions': {'1': {}, '2': {}}}}}
56
57 util.products_condense(tree)
58 self.assertEqual(tree, exp)
59@@ -168,8 +177,8 @@
60 tree = {'products': {'P1': {'A': 'B',
61 'versions': {'1': {'A': 'B'},
62 '2': {'A': 'B'}}}}}
63- exp = {'products': {'P1': {'versions': {'1': {}, '2': {}},
64- 'A': 'B'}}}
65+ exp = {'A': 'B',
66+ 'products': {'P1': {'versions': {'1': {}, '2': {}}}}}
67
68 util.products_condense(tree)
69 self.assertEqual(tree, exp)
70@@ -178,8 +187,8 @@
71 tree = {'products': {'P1': {'A': 'C',
72 'versions': {'1': {'A': 'B'},
73 '2': {'A': 'B'}}}}}
74- exp = {'products': {'P1': {'A': 'C',
75- 'versions': {'1': {'A': 'B'},
76+ exp = {'A': 'C',
77+ 'products': {'P1': {'versions': {'1': {'A': 'B'},
78 '2': {'A': 'B'}}}}}
79
80 util.products_condense(tree)

Subscribers

People subscribed via source and target branches

to all changes: