Merge lp://staging/~fwereade/pyjuju/add-upstart-class into lp://staging/pyjuju

Proposed by William Reade
Status: Merged
Approved by: Kapil Thangavelu
Approved revision: 446
Merged at revision: 459
Proposed branch: lp://staging/~fwereade/pyjuju/add-upstart-class
Merge into: lp://staging/pyjuju
Prerequisite: lp://staging/~fwereade/pyjuju/fix-charm-upgrade
Diff against target: 427 lines (+375/-1)
7 files modified
juju/errors.py (+3/-0)
juju/lib/tests/data/test_basic_install (+10/-0)
juju/lib/tests/data/test_less_basic_install (+11/-0)
juju/lib/tests/data/test_standard_install (+10/-0)
juju/lib/tests/test_upstart.py (+229/-0)
juju/lib/upstart.py (+105/-0)
juju/tests/test_errors.py (+7/-1)
To merge this branch: bzr merge lp://staging/~fwereade/pyjuju/add-upstart-class
Reviewer Review Type Date Requested Status
Kapil Thangavelu (community) Approve
Jim Baker (community) Approve
Review via email: mp+85335@code.staging.launchpad.net

Description of the change

This is just the class we will be using in lp:~fwereade/juju/upstartify-services, but extracted so as to make the diffs a little less daunting.

To post a comment you must log in.
440. By William Reade

merge parent

441. By William Reade

merge parent

442. By William Reade

merge parent

Revision history for this message
Jim Baker (jimbaker) wrote :

+1. Just minors here:

[1]

+description "blah"
+author "Juju Team <email address hidden>"
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+respawn
+
+env BLAH="blah blah"
+
+exec /bin/imagination-failure --no-ideas

Having a generating family of dummy data (eg your Star Wars theme or really whatever)
can be helpful for seeing the expected patterns. "blah blah" is unfortunately
just too much noise when looking at these tests.

The other thing is that putting these files inline might work much better, to avoid one
more place to look to see what the expected output should be.

[2]

+class UpstartServiceTest(TestCase):
+
+ def setUp(self):
+ self.root = self.makeDir()
+ init_dir = os.path.join(self.root, "etc", "init")
+ os.makedirs(init_dir)
+ self.conf = os.path.join(init_dir, "some-name.conf")
+ self.patch(UpstartService, "root_path", self.root)
+ self.service = UpstartService("some-name")

It's unlikely this will be mixed in with other tests, but it's likely best to preserve
the existing cooperative super inheritance support, including returning a Deferred
(usually by inlineCallbacks).

[3]

+ def test_is_installed(self):

Doc strings for tests!

+ self.assertFalse(self.service.is_installed())
+ self.write_dummy_conf()
+ self.assertTrue(self.service.is_installed())
+

[4]

+ @inlineCallbacks
+ def test_is_running(self):

Docs/comments especially here. Best to be explicit about how the mocks are
setting things up, especially when there's a sequence of multiple calls as seen here.

review: Approve
443. By William Reade

merge parent

444. By William Reade

address review points

445. By William Reade

merge parent

446. By William Reade

merge parent

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

lgtm +1, some minors

[0]

    # on class for ease of mocking

s/mocking/testing

[1]

+ self.conf = os.path.join(init_dir, "some-name.conf")

pep8 cheese, double space after =

[2]

+ def set_start_on_filesystem(self):
+ self._start_on_filesystem = True

this line is never tested, nor entirely clear on usage. There are several upstart gurus in the room if this needs clarification.

[3] more untested lines

+ self.root_path = root_path

its not clear why this mocked out as a class attribute, when the constructor takes the arg.

+ raise ServiceError("Cannot render .conf: no description set")
+ raise ServiceError("Cannot render .conf: no command set")

review: Approve
Revision history for this message
William Reade (fwereade) wrote :

[0,1]

Cool, thanks

[2,3]

...gaah, missing @inlineCallbacks~s led to some untestedness; root_path tested explicitly. After consultation with bcsaller (original author), it's fine to drop the "start on filesystem or" complication, so it's gone.

447. By William Reade

address review points

448. By William Reade

merge parent

449. By William Reade

merge parent

450. By William Reade

merge parent

451. By William Reade

merge parent

452. By William Reade

merge parent

453. By William Reade

merge parent

454. By William Reade

merge parent

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: