Merge lp:~robru/cupstream2distro/safer-silo-dir into lp:cupstream2distro

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 1105
Merged at revision: 1105
Proposed branch: lp:~robru/cupstream2distro/safer-silo-dir
Merge into: lp:cupstream2distro
Diff against target: 163 lines (+6/-16)
7 files modified
cupstream2distro/utils.py (+1/-0)
tests/unit/__init__.py (+1/-0)
tests/unit/test_recipe_base.py (+0/-3)
tests/unit/test_recipe_manual.py (+1/-2)
tests/unit/test_recipe_secondary.py (+0/-3)
tests/unit/test_recipe_sourcesync.py (+2/-6)
tests/unit/test_utils.py (+1/-2)
To merge this branch: bzr merge lp:~robru/cupstream2distro/safer-silo-dir
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
CU2D maintainers Pending
Review via email: mp+271912@code.launchpad.net

Commit message

Add an assert to prevent a certain class of horrible accidents.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/utils.py'
2--- cupstream2distro/utils.py 2015-09-21 21:35:43 +0000
3+++ cupstream2distro/utils.py 2015-09-22 06:55:04 +0000
4@@ -163,6 +163,7 @@
5
6 def SILO_DIR(*parts):
7 """Return the directory of the currently active silo."""
8+ assert env.SILONAME
9 return join(SILOS_DIR, env.SILONAME, *parts)
10
11
12
13=== modified file 'tests/unit/__init__.py'
14--- tests/unit/__init__.py 2015-09-11 19:50:59 +0000
15+++ tests/unit/__init__.py 2015-09-22 06:55:04 +0000
16@@ -54,6 +54,7 @@
17 """Time how long each test runs."""
18 super().setUp()
19 self.start_time = time.time()
20+ env.SILONAME = self.tempdir
21
22 def tearDown(self):
23 """Delete that temporary working directory, if it was created."""
24
25=== modified file 'tests/unit/test_recipe_base.py'
26--- tests/unit/test_recipe_base.py 2015-09-21 21:35:43 +0000
27+++ tests/unit/test_recipe_base.py 2015-09-22 06:55:04 +0000
28@@ -376,7 +376,6 @@
29 @patch('citrain.recipes.base.newest')
30 def test_buildbase_diff_phase(self, new_mock, glob_mock):
31 """Generate a diff between our build & what's at dest."""
32- env.SILONAME = ''
33 glob_results = [['new_dsc'], ['old_dsc']]
34 glob_mock.side_effect = lambda *i: glob_results.pop()
35 build = BuildBase('bar', self.series, self.dest, self.ppa)
36@@ -397,7 +396,6 @@
37 @patch('citrain.recipes.base.newest')
38 def test_buildbase_diff_phase_new_source(self, new_mock, glob_mock):
39 """Indicate that this package was never released at dest."""
40- env.SILONAME = ''
41 glob_results = [['new_dsc'], []]
42 glob_mock.side_effect = lambda *i: glob_results.pop()
43 build = BuildBase('bar', self.series, self.dest, self.ppa)
44@@ -417,7 +415,6 @@
45 @patch('citrain.recipes.base.newest')
46 def test_buildbase_diff_phase_dest_ppa(self, new_mock, glob_mock):
47 """Generate diff from main archive when dest PPA missing source."""
48- env.SILONAME = ''
49 glob_results = [['new_dsc'], []]
50 glob_mock.side_effect = lambda *i: glob_results.pop()
51 new_mock.return_value = None
52
53=== modified file 'tests/unit/test_recipe_manual.py'
54--- tests/unit/test_recipe_manual.py 2015-09-02 03:04:53 +0000
55+++ tests/unit/test_recipe_manual.py 2015-09-22 06:55:04 +0000
56@@ -62,7 +62,6 @@
57 """Fetch manual source uploads from silo PPA for diffing."""
58 manual = Manual('zappy', self.series, self.dest, self.ppa)
59 manual.get_from_archive.return_value = 'package_dir'
60- env.SILONAME = ''
61 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
62 manual.diff_phase()
63 cs_mock.assert_called_once_with('zappy')
64@@ -70,7 +69,7 @@
65 call(self.ppa), call(self.dest),
66 ])
67 manual.get_from_archive.assert_called_once_with(
68- self.tempdir + '/', manual.silo_ppa)
69+ self.tempdir, manual.silo_ppa)
70 BuildBase.diff_phase.assert_called_once_with()
71
72 def test_manual_ackaging(self):
73
74=== modified file 'tests/unit/test_recipe_secondary.py'
75--- tests/unit/test_recipe_secondary.py 2015-09-10 02:05:59 +0000
76+++ tests/unit/test_recipe_secondary.py 2015-09-22 06:55:04 +0000
77@@ -22,7 +22,6 @@
78 from tests.unit import DirectoryAwareTestCase
79
80 from citrain.recipes.secondary import Secondary
81-from cupstream2distro.utils import env
82
83
84 MOD = 'citrain.recipes.secondary.'
85@@ -47,7 +46,6 @@
86 def test_secondary_nops(self, lp_mock):
87 """Ensure certain secondary methods do nothing."""
88 lp_mock.load.return_value.name = 'vivid'
89- env.SILONAME = ''
90 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
91 sec = Secondary('foo', self.series, self.dest, self.ppa)
92 lp_mock.load.assert_called_once_with(
93@@ -74,7 +72,6 @@
94 os_mock.path.isdir.return_value = True
95 lp_mock.load.return_value.name = 'vivid'
96 lp_mock.load.return_value.version = '15.04'
97- env.SILONAME = ''
98 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
99 sec = Secondary('foo', self.series, self.dest, self.ppa)
100 sec.get_package_version.return_value = '0+15.10.20150525-0ubuntu1'
101
102=== modified file 'tests/unit/test_recipe_sourcesync.py'
103--- tests/unit/test_recipe_sourcesync.py 2015-09-05 01:42:54 +0000
104+++ tests/unit/test_recipe_sourcesync.py 2015-09-22 06:55:04 +0000
105@@ -22,7 +22,6 @@
106
107 from citrain.recipes.sourcesync import SourceSync
108 from cupstream2distro.errors import BuildError
109-from cupstream2distro.utils import env
110
111
112 MOD = 'citrain.recipes.sourcesync.'
113@@ -64,7 +63,6 @@
114 sync.get_archive_version.return_value = '1+15.04.20150208~rtm-0ubuntu1'
115 sync.get_package_version\
116 .return_value = '1+15.04.20150208~rtm-0ubuntu1'
117- env.SILONAME = ''
118 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
119 sync.collect_phase()
120 self.assertEqual(glob_mock.mock_calls, [
121@@ -72,7 +70,7 @@
122 call(self.tempdir + '/sink_*.orig.*'),
123 ])
124 sync.get_from_archive.assert_called_once_with(
125- self.tempdir + '/',
126+ self.tempdir,
127 SourceSync.from_archive,
128 SourceSync.from_series,
129 status='Published')
130@@ -122,7 +120,6 @@
131 sync.get_archive_version.return_value = '1+15.04.20150208-0ubuntu1'
132 sync.get_package_version\
133 .return_value = '1+15.10.20150210-0ubuntu1'
134- env.SILONAME = ''
135 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
136 sync.collect_phase()
137 sync.initialize_branch.assert_called_once_with()
138@@ -172,10 +169,9 @@
139 SourceSync.from_series.name = 'vivid'
140 sync = SourceSync('sink', self.series, self.dest, self.ppa)
141 sync.get_from_archive.return_value = None
142- env.SILONAME = ''
143 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
144 with self.assertRaisesRegexp(BuildError, 'sink not found'):
145 sync.collect_phase()
146 sync.get_from_archive.assert_called_once_with(
147- self.tempdir + '/', sync.from_archive, sync.from_series,
148+ self.tempdir, sync.from_archive, sync.from_series,
149 status='Published')
150
151=== modified file 'tests/unit/test_utils.py'
152--- tests/unit/test_utils.py 2015-09-10 02:05:59 +0000
153+++ tests/unit/test_utils.py 2015-09-22 06:55:04 +0000
154@@ -121,8 +121,7 @@
155
156 def test_silo_dir(self):
157 """SILO_DIR() function can find the correct silo dir dynamically."""
158- env.SILONAME = ''
159- self.assertEqual(SILO_DIR(), os.path.expanduser('~/silos/'))
160+ self.assertEqual(SILO_DIR(), os.path.expanduser(self.tempdir))
161 env.SILONAME = 'ubuntu/landing-123'
162 self.assertEqual(
163 SILO_DIR(), os.path.expanduser('~/silos/ubuntu/landing-123'))

Subscribers

People subscribed via source and target branches