Merge lp:~clint-fewbar/pyjuju/no-lsb-release into lp:pyjuju

Proposed by Clint Byrum
Status: Merged
Approved by: Jim Baker
Approved revision: 599
Merged at revision: 599
Proposed branch: lp:~clint-fewbar/pyjuju/no-lsb-release
Merge into: lp:pyjuju
Diff against target: 30 lines (+10/-8)
1 file modified
juju/charm/tests/test_directory.py (+10/-8)
To merge this branch: bzr merge lp:~clint-fewbar/pyjuju/no-lsb-release
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+130929@code.launchpad.net

Description of the change

Fixes tests relying on /etc/lsb-release

Fixes tests relying on /etc/lsb-release

https://codereview.appspot.com/6750055/

To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Reviewers: mp+130929_code.launchpad.net,

Message:
Please take a look.

Description:
Fixes tests relying on /etc/lsb-release

Fixes tests relying on /etc/lsb-release

https://code.launchpad.net/~clint-fewbar/juju/no-lsb-release/+merge/130929

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/6750055/

Affected files:
   A [revision details]
   M juju/charm/tests/test_directory.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: juju/charm/tests/test_directory.py
=== modified file 'juju/charm/tests/test_directory.py'
--- juju/charm/tests/test_directory.py 2012-09-14 15:33:33 +0000
+++ juju/charm/tests/test_directory.py 2012-10-23 03:30:14 +0000
@@ -212,16 +212,18 @@

      def test_internal_symlink(self):
          charm_path = self.copy_charm()
- os.symlink("/etc/lsb-release", os.path.join(charm_path, "foobar"))
+ with tempfile.NamedTemporaryFile(dir='/tmp') as external_file:
+ os.symlink(external_file.name,
os.path.join(charm_path, "foobar"))

- directory = CharmDirectory(charm_path)
- e = self.assertRaises(InvalidCharmFile, directory.as_bundle)
- self.assertIn("foobar' Absolute links are invalid", str(e))
+ directory = CharmDirectory(charm_path)
+ e = self.assertRaises(InvalidCharmFile, directory.as_bundle)
+ self.assertIn("foobar' Absolute links are invalid", str(e))

      def test_extract_symlink(self):
          charm_path = self.copy_charm()
- os.symlink("/etc/lsb-release", os.path.join(charm_path, "foobar"))
+ with tempfile.NamedTemporaryFile(dir='/tmp') as external_file:
+ os.symlink(external_file.name,
os.path.join(charm_path, "foobar"))

- directory = CharmDirectory(charm_path)
- e = self.assertRaises(InvalidCharmFile, directory.as_bundle)
- self.assertIn("foobar' Absolute links are invalid", str(e))
+ directory = CharmDirectory(charm_path)
+ e = self.assertRaises(InvalidCharmFile, directory.as_bundle)
+ self.assertIn("foobar' Absolute links are invalid", str(e))

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

+1, LGTM, with the following coding convention minor addressed.

https://codereview.appspot.com/6750055/diff/1/juju/charm/tests/test_directory.py
File juju/charm/tests/test_directory.py (right):

https://codereview.appspot.com/6750055/diff/1/juju/charm/tests/test_directory.py#newcode215
juju/charm/tests/test_directory.py:215: with
tempfile.NamedTemporaryFile(dir='/tmp') as external_file:
Use the makeFile method on our TestCase; it constructs a temporary file
as above, but also ensures it is deleted at the end of the test. This
method is used throughout our tests, so this will help with following
current coding conventions.

external_file = self.makeFile()

https://codereview.appspot.com/6750055/diff/1/juju/charm/tests/test_directory.py#newcode224
juju/charm/tests/test_directory.py:224: with
tempfile.NamedTemporaryFile(dir='/tmp') as external_file:
Ditto.

https://codereview.appspot.com/6750055/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'juju/charm/tests/test_directory.py'
--- juju/charm/tests/test_directory.py 2012-09-14 15:33:33 +0000
+++ juju/charm/tests/test_directory.py 2012-10-23 03:32:18 +0000
@@ -212,16 +212,18 @@
212212
213 def test_internal_symlink(self):213 def test_internal_symlink(self):
214 charm_path = self.copy_charm()214 charm_path = self.copy_charm()
215 os.symlink("/etc/lsb-release", os.path.join(charm_path, "foobar"))215 with tempfile.NamedTemporaryFile(dir='/tmp') as external_file:
216 os.symlink(external_file.name, os.path.join(charm_path, "foobar"))
216217
217 directory = CharmDirectory(charm_path)218 directory = CharmDirectory(charm_path)
218 e = self.assertRaises(InvalidCharmFile, directory.as_bundle)219 e = self.assertRaises(InvalidCharmFile, directory.as_bundle)
219 self.assertIn("foobar' Absolute links are invalid", str(e))220 self.assertIn("foobar' Absolute links are invalid", str(e))
220221
221 def test_extract_symlink(self):222 def test_extract_symlink(self):
222 charm_path = self.copy_charm()223 charm_path = self.copy_charm()
223 os.symlink("/etc/lsb-release", os.path.join(charm_path, "foobar"))224 with tempfile.NamedTemporaryFile(dir='/tmp') as external_file:
225 os.symlink(external_file.name, os.path.join(charm_path, "foobar"))
224226
225 directory = CharmDirectory(charm_path)227 directory = CharmDirectory(charm_path)
226 e = self.assertRaises(InvalidCharmFile, directory.as_bundle)228 e = self.assertRaises(InvalidCharmFile, directory.as_bundle)
227 self.assertIn("foobar' Absolute links are invalid", str(e))229 self.assertIn("foobar' Absolute links are invalid", str(e))

Subscribers

People subscribed via source and target branches

to status/vote changes: