summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2012-05-22 15:19:54 +0200
committerDidier Raboud <odyx@debian.org>2012-05-22 15:19:56 +0200
commitf6bf9ebeac9bae1464bfe6f5278bfc0bc2551658 (patch)
tree899e78b1d19930fc47484ae35901c04b5b2b56b9 /test
parentbfa47108c06cb03f762e9f3eae2833cabb2fcb44 (diff)
PyUT: Implement test for lsb_release.get_lsb_information.
This includes a modification of lsb_release.py to enable an overridability with an environment variable LSB_ETC_LSB_RELEASE that can point to another /etc/lsb-release
Diffstat (limited to 'test')
-rw-r--r--test/lsb-release5
-rw-r--r--test/test_lsb_release.py15
2 files changed, 18 insertions, 2 deletions
diff --git a/test/lsb-release b/test/lsb-release
new file mode 100644
index 0000000..06d7473
--- /dev/null
+++ b/test/lsb-release
@@ -0,0 +1,5 @@
+DISTRIB_ID=(Distributor ID)
+DISTRIB_DESCRIPTION=(A human-readable description of the release)
+DISTRIB_RELEASE=(The release number)
+DISTRIB_CODENAME=(The codename for the release)
+OTHER_VARIABLE=Not supposed to exist
diff --git a/test/test_lsb_release.py b/test/test_lsb_release.py
index ef08540..eecd4e8 100644
--- a/test/test_lsb_release.py
+++ b/test/test_lsb_release.py
@@ -132,9 +132,20 @@ class TestLSBRelease(unittest.TestCase):
@unittest.skip('Test not implemented.')
def test_guess_debian_release(self):
raise NotImplementedError()
- @unittest.skip('Test not implemented.')
+
def test_get_lsb_information(self):
- raise NotImplementedError()
+ # Test that an inexistant /etc/lsb-release leads to empty output
+ supposed_output = {}
+ os.environ['LSB_ETC_LSB_RELEASE'] = 'test/inexistant_file_' + rnd_string(2,5)
+ self.assertEqual(lr.get_lsb_information(),supposed_output)
+ # Test that a fake /etc/lsb-release leads to output with only the content we want
+ supposed_output = {'RELEASE': '(The release number)',
+ 'CODENAME': '(The codename for the release)',
+ 'ID': '(Distributor ID)',
+ 'DESCRIPTION': '(A human-readable description of the release)'}
+ os.environ['LSB_ETC_LSB_RELEASE'] = 'test/lsb-release'
+ self.assertEqual(lr.get_lsb_information(),supposed_output)
+
@unittest.skip('Test not implemented.')
def test_get_distro_information(self):
raise NotImplementedError()