Merge lp:~thomir-deactivatedaccount/adt-continuous-deployer/trunk-fix-mojo-project-pool-bug into lp:adt-continuous-deployer

Proposed by Thomi Richards
Status: Merged
Approved by: Celso Providelo
Approved revision: 59
Merged at revision: 59
Proposed branch: lp:~thomir-deactivatedaccount/adt-continuous-deployer/trunk-fix-mojo-project-pool-bug
Merge into: lp:adt-continuous-deployer
Diff against target: 57 lines (+12/-6)
2 files modified
ci_automation/mojo_project_pool.py (+4/-1)
ci_automation/tests/test_mojo_project_pool.py (+8/-5)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/adt-continuous-deployer/trunk-fix-mojo-project-pool-bug
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+261054@code.launchpad.net

Commit message

Fix a bug where the 'locks' directory could be selected as a project name in the project pool code.

Description of the change

Fix a bug where the 'locks' directory could be selected as a project name in the project pool code.

Also several drive-by pep8 fixes in the tests.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ci_automation/mojo_project_pool.py'
2--- ci_automation/mojo_project_pool.py 2015-05-28 03:14:00 +0000
3+++ ci_automation/mojo_project_pool.py 2015-06-04 00:37:24 +0000
4@@ -74,7 +74,10 @@
5 If no project can be found, a NoProjectError exception is raised.
6
7 """
8- candidates = os.listdir(self.project_dir)
9+ candidates = [
10+ f for f in os.listdir(self.project_dir)
11+ if os.path.isfile(os.path.join(self.project_dir, f))
12+ ]
13 random.shuffle(candidates)
14 for candidate_project in candidates:
15 try:
16
17=== modified file 'ci_automation/tests/test_mojo_project_pool.py'
18--- ci_automation/tests/test_mojo_project_pool.py 2015-05-28 03:14:00 +0000
19+++ ci_automation/tests/test_mojo_project_pool.py 2015-06-04 00:37:24 +0000
20@@ -48,13 +48,13 @@
21
22 def test_can_acquire_single_project(self):
23 with ProjectPoolDir(projects=['project-one']) as workdir:
24- pool = MojoProjectPool(workdir.project_dir,workdir.lock_dir)
25+ pool = MojoProjectPool(workdir.project_dir, workdir.lock_dir)
26 with pool.acquire_mojo_project() as project:
27 self.assertEqual(project, 'project-one')
28
29 def test_can_acquire_single_project_once_only(self):
30 with ProjectPoolDir(projects=['project-one']) as workdir:
31- pool = MojoProjectPool(workdir.project_dir,workdir.lock_dir)
32+ pool = MojoProjectPool(workdir.project_dir, workdir.lock_dir)
33 with pool.acquire_mojo_project() as project:
34 self.assertEqual(project, 'project-one')
35 with self.assertRaises(NoProjectError):
36@@ -63,15 +63,18 @@
37
38 def test_can_acquire_multiple_projects(self):
39 with ProjectPoolDir(projects=['one', 'two']) as workdir:
40- pool = MojoProjectPool(workdir.project_dir,workdir.lock_dir)
41- with pool.acquire_mojo_project() as p1, pool.acquire_mojo_project() as p2:
42+ pool = MojoProjectPool(workdir.project_dir, workdir.lock_dir)
43+ with (
44+ pool.acquire_mojo_project() as p1,
45+ pool.acquire_mojo_project() as p2
46+ ):
47 self.assertNotEqual(p1, p2)
48 self.assertIn(p1, ('one', 'two'))
49 self.assertIn(p2, ('one', 'two'))
50
51 def test_uncaught_exception_releases_lock(self):
52 with ProjectPoolDir(projects=['project-one']) as workdir:
53- pool = MojoProjectPool(workdir.project_dir,workdir.lock_dir)
54+ pool = MojoProjectPool(workdir.project_dir, workdir.lock_dir)
55 try:
56 with pool.acquire_mojo_project() as project:
57 raise Exception("Pretending mojo failed!")

Subscribers

People subscribed via source and target branches

to all changes: