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
=== modified file 'cupstream2distro/utils.py'
--- cupstream2distro/utils.py 2015-09-21 21:35:43 +0000
+++ cupstream2distro/utils.py 2015-09-22 06:55:04 +0000
@@ -163,6 +163,7 @@
163163
164def SILO_DIR(*parts):164def SILO_DIR(*parts):
165 """Return the directory of the currently active silo."""165 """Return the directory of the currently active silo."""
166 assert env.SILONAME
166 return join(SILOS_DIR, env.SILONAME, *parts)167 return join(SILOS_DIR, env.SILONAME, *parts)
167168
168169
169170
=== modified file 'tests/unit/__init__.py'
--- tests/unit/__init__.py 2015-09-11 19:50:59 +0000
+++ tests/unit/__init__.py 2015-09-22 06:55:04 +0000
@@ -54,6 +54,7 @@
54 """Time how long each test runs."""54 """Time how long each test runs."""
55 super().setUp()55 super().setUp()
56 self.start_time = time.time()56 self.start_time = time.time()
57 env.SILONAME = self.tempdir
5758
58 def tearDown(self):59 def tearDown(self):
59 """Delete that temporary working directory, if it was created."""60 """Delete that temporary working directory, if it was created."""
6061
=== modified file 'tests/unit/test_recipe_base.py'
--- tests/unit/test_recipe_base.py 2015-09-21 21:35:43 +0000
+++ tests/unit/test_recipe_base.py 2015-09-22 06:55:04 +0000
@@ -376,7 +376,6 @@
376 @patch('citrain.recipes.base.newest')376 @patch('citrain.recipes.base.newest')
377 def test_buildbase_diff_phase(self, new_mock, glob_mock):377 def test_buildbase_diff_phase(self, new_mock, glob_mock):
378 """Generate a diff between our build & what's at dest."""378 """Generate a diff between our build & what's at dest."""
379 env.SILONAME = ''
380 glob_results = [['new_dsc'], ['old_dsc']]379 glob_results = [['new_dsc'], ['old_dsc']]
381 glob_mock.side_effect = lambda *i: glob_results.pop()380 glob_mock.side_effect = lambda *i: glob_results.pop()
382 build = BuildBase('bar', self.series, self.dest, self.ppa)381 build = BuildBase('bar', self.series, self.dest, self.ppa)
@@ -397,7 +396,6 @@
397 @patch('citrain.recipes.base.newest')396 @patch('citrain.recipes.base.newest')
398 def test_buildbase_diff_phase_new_source(self, new_mock, glob_mock):397 def test_buildbase_diff_phase_new_source(self, new_mock, glob_mock):
399 """Indicate that this package was never released at dest."""398 """Indicate that this package was never released at dest."""
400 env.SILONAME = ''
401 glob_results = [['new_dsc'], []]399 glob_results = [['new_dsc'], []]
402 glob_mock.side_effect = lambda *i: glob_results.pop()400 glob_mock.side_effect = lambda *i: glob_results.pop()
403 build = BuildBase('bar', self.series, self.dest, self.ppa)401 build = BuildBase('bar', self.series, self.dest, self.ppa)
@@ -417,7 +415,6 @@
417 @patch('citrain.recipes.base.newest')415 @patch('citrain.recipes.base.newest')
418 def test_buildbase_diff_phase_dest_ppa(self, new_mock, glob_mock):416 def test_buildbase_diff_phase_dest_ppa(self, new_mock, glob_mock):
419 """Generate diff from main archive when dest PPA missing source."""417 """Generate diff from main archive when dest PPA missing source."""
420 env.SILONAME = ''
421 glob_results = [['new_dsc'], []]418 glob_results = [['new_dsc'], []]
422 glob_mock.side_effect = lambda *i: glob_results.pop()419 glob_mock.side_effect = lambda *i: glob_results.pop()
423 new_mock.return_value = None420 new_mock.return_value = None
424421
=== modified file 'tests/unit/test_recipe_manual.py'
--- tests/unit/test_recipe_manual.py 2015-09-02 03:04:53 +0000
+++ tests/unit/test_recipe_manual.py 2015-09-22 06:55:04 +0000
@@ -62,7 +62,6 @@
62 """Fetch manual source uploads from silo PPA for diffing."""62 """Fetch manual source uploads from silo PPA for diffing."""
63 manual = Manual('zappy', self.series, self.dest, self.ppa)63 manual = Manual('zappy', self.series, self.dest, self.ppa)
64 manual.get_from_archive.return_value = 'package_dir'64 manual.get_from_archive.return_value = 'package_dir'
65 env.SILONAME = ''
66 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):65 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
67 manual.diff_phase()66 manual.diff_phase()
68 cs_mock.assert_called_once_with('zappy')67 cs_mock.assert_called_once_with('zappy')
@@ -70,7 +69,7 @@
70 call(self.ppa), call(self.dest),69 call(self.ppa), call(self.dest),
71 ])70 ])
72 manual.get_from_archive.assert_called_once_with(71 manual.get_from_archive.assert_called_once_with(
73 self.tempdir + '/', manual.silo_ppa)72 self.tempdir, manual.silo_ppa)
74 BuildBase.diff_phase.assert_called_once_with()73 BuildBase.diff_phase.assert_called_once_with()
7574
76 def test_manual_ackaging(self):75 def test_manual_ackaging(self):
7776
=== modified file 'tests/unit/test_recipe_secondary.py'
--- tests/unit/test_recipe_secondary.py 2015-09-10 02:05:59 +0000
+++ tests/unit/test_recipe_secondary.py 2015-09-22 06:55:04 +0000
@@ -22,7 +22,6 @@
22from tests.unit import DirectoryAwareTestCase22from tests.unit import DirectoryAwareTestCase
2323
24from citrain.recipes.secondary import Secondary24from citrain.recipes.secondary import Secondary
25from cupstream2distro.utils import env
2625
2726
28MOD = 'citrain.recipes.secondary.'27MOD = 'citrain.recipes.secondary.'
@@ -47,7 +46,6 @@
47 def test_secondary_nops(self, lp_mock):46 def test_secondary_nops(self, lp_mock):
48 """Ensure certain secondary methods do nothing."""47 """Ensure certain secondary methods do nothing."""
49 lp_mock.load.return_value.name = 'vivid'48 lp_mock.load.return_value.name = 'vivid'
50 env.SILONAME = ''
51 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):49 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
52 sec = Secondary('foo', self.series, self.dest, self.ppa)50 sec = Secondary('foo', self.series, self.dest, self.ppa)
53 lp_mock.load.assert_called_once_with(51 lp_mock.load.assert_called_once_with(
@@ -74,7 +72,6 @@
74 os_mock.path.isdir.return_value = True72 os_mock.path.isdir.return_value = True
75 lp_mock.load.return_value.name = 'vivid'73 lp_mock.load.return_value.name = 'vivid'
76 lp_mock.load.return_value.version = '15.04'74 lp_mock.load.return_value.version = '15.04'
77 env.SILONAME = ''
78 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):75 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
79 sec = Secondary('foo', self.series, self.dest, self.ppa)76 sec = Secondary('foo', self.series, self.dest, self.ppa)
80 sec.get_package_version.return_value = '0+15.10.20150525-0ubuntu1'77 sec.get_package_version.return_value = '0+15.10.20150525-0ubuntu1'
8178
=== modified file 'tests/unit/test_recipe_sourcesync.py'
--- tests/unit/test_recipe_sourcesync.py 2015-09-05 01:42:54 +0000
+++ tests/unit/test_recipe_sourcesync.py 2015-09-22 06:55:04 +0000
@@ -22,7 +22,6 @@
2222
23from citrain.recipes.sourcesync import SourceSync23from citrain.recipes.sourcesync import SourceSync
24from cupstream2distro.errors import BuildError24from cupstream2distro.errors import BuildError
25from cupstream2distro.utils import env
2625
2726
28MOD = 'citrain.recipes.sourcesync.'27MOD = 'citrain.recipes.sourcesync.'
@@ -64,7 +63,6 @@
64 sync.get_archive_version.return_value = '1+15.04.20150208~rtm-0ubuntu1'63 sync.get_archive_version.return_value = '1+15.04.20150208~rtm-0ubuntu1'
65 sync.get_package_version\64 sync.get_package_version\
66 .return_value = '1+15.04.20150208~rtm-0ubuntu1'65 .return_value = '1+15.04.20150208~rtm-0ubuntu1'
67 env.SILONAME = ''
68 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):66 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
69 sync.collect_phase()67 sync.collect_phase()
70 self.assertEqual(glob_mock.mock_calls, [68 self.assertEqual(glob_mock.mock_calls, [
@@ -72,7 +70,7 @@
72 call(self.tempdir + '/sink_*.orig.*'),70 call(self.tempdir + '/sink_*.orig.*'),
73 ])71 ])
74 sync.get_from_archive.assert_called_once_with(72 sync.get_from_archive.assert_called_once_with(
75 self.tempdir + '/',73 self.tempdir,
76 SourceSync.from_archive,74 SourceSync.from_archive,
77 SourceSync.from_series,75 SourceSync.from_series,
78 status='Published')76 status='Published')
@@ -122,7 +120,6 @@
122 sync.get_archive_version.return_value = '1+15.04.20150208-0ubuntu1'120 sync.get_archive_version.return_value = '1+15.04.20150208-0ubuntu1'
123 sync.get_package_version\121 sync.get_package_version\
124 .return_value = '1+15.10.20150210-0ubuntu1'122 .return_value = '1+15.10.20150210-0ubuntu1'
125 env.SILONAME = ''
126 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):123 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
127 sync.collect_phase()124 sync.collect_phase()
128 sync.initialize_branch.assert_called_once_with()125 sync.initialize_branch.assert_called_once_with()
@@ -172,10 +169,9 @@
172 SourceSync.from_series.name = 'vivid'169 SourceSync.from_series.name = 'vivid'
173 sync = SourceSync('sink', self.series, self.dest, self.ppa)170 sync = SourceSync('sink', self.series, self.dest, self.ppa)
174 sync.get_from_archive.return_value = None171 sync.get_from_archive.return_value = None
175 env.SILONAME = ''
176 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):172 with patch('cupstream2distro.utils.SILOS_DIR', self.tempdir):
177 with self.assertRaisesRegexp(BuildError, 'sink not found'):173 with self.assertRaisesRegexp(BuildError, 'sink not found'):
178 sync.collect_phase()174 sync.collect_phase()
179 sync.get_from_archive.assert_called_once_with(175 sync.get_from_archive.assert_called_once_with(
180 self.tempdir + '/', sync.from_archive, sync.from_series,176 self.tempdir, sync.from_archive, sync.from_series,
181 status='Published')177 status='Published')
182178
=== modified file 'tests/unit/test_utils.py'
--- tests/unit/test_utils.py 2015-09-10 02:05:59 +0000
+++ tests/unit/test_utils.py 2015-09-22 06:55:04 +0000
@@ -121,8 +121,7 @@
121121
122 def test_silo_dir(self):122 def test_silo_dir(self):
123 """SILO_DIR() function can find the correct silo dir dynamically."""123 """SILO_DIR() function can find the correct silo dir dynamically."""
124 env.SILONAME = ''124 self.assertEqual(SILO_DIR(), os.path.expanduser(self.tempdir))
125 self.assertEqual(SILO_DIR(), os.path.expanduser('~/silos/'))
126 env.SILONAME = 'ubuntu/landing-123'125 env.SILONAME = 'ubuntu/landing-123'
127 self.assertEqual(126 self.assertEqual(
128 SILO_DIR(), os.path.expanduser('~/silos/ubuntu/landing-123'))127 SILO_DIR(), os.path.expanduser('~/silos/ubuntu/landing-123'))

Subscribers

People subscribed via source and target branches