Skip to content

Commit

Permalink
logind tests: Adjust to also accept output format of systemd 215
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpitt committed Sep 19, 2014
1 parent f1e2b19 commit 39a807c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion NEWS
Expand Up @@ -10,7 +10,8 @@
Thanks Jonas Grønås Drange.
- bluez5 tests: Accept devices in state "not available" (or other states) as
well.
- timedated tests: Adjust to also accept output format of systemd 215.
- timedated and logind tests: Adjust to also accept output format of
systemd 215.

0.11.1 (2014-08-08)
-------------------
Expand Down
22 changes: 15 additions & 7 deletions tests/test_logind.py
Expand Up @@ -32,6 +32,10 @@ def setUpClass(klass):
klass.start_system_bus()
klass.dbus_con = klass.get_dbus(True)

out = subprocess.check_output(['loginctl', '--version'],
universal_newlines=True)
klass.version = out.splitlines()[0].split()[-1]

def setUp(self):
self.p_mock = None

Expand All @@ -42,15 +46,18 @@ def tearDown(self):

def test_empty(self):
(self.p_mock, _) = self.spawn_server_template('logind', {}, stdout=subprocess.PIPE)
out = subprocess.check_output(['loginctl', 'list-sessions'],
cmd = ['loginctl']
if self.version >= '209':
cmd.append('--no-legend')
out = subprocess.check_output(cmd + ['list-sessions'],
universal_newlines=True)
self.assertEqual(out, '')

out = subprocess.check_output(['loginctl', 'list-seats'],
out = subprocess.check_output(cmd + ['list-seats'],
universal_newlines=True)
self.assertEqual(out, '')

out = subprocess.check_output(['loginctl', 'list-users'],
out = subprocess.check_output(cmd + ['list-users'],
universal_newlines=True)
self.assertEqual(out, '')

Expand All @@ -61,17 +68,18 @@ def test_session(self):

out = subprocess.check_output(['loginctl', 'list-seats'],
universal_newlines=True)
self.assertRegex(out, '^seat0 +$')
self.assertRegex(out, '(^|\n)seat0\s+')

out = subprocess.check_output(['loginctl', 'show-seat', 'seat0'],
universal_newlines=True)
self.assertRegex(out, 'Id=seat0')
self.assertRegex(out, 'ActiveSession=c1')
self.assertRegex(out, 'Sessions=c1')
if self.version <= '208':
self.assertRegex(out, 'ActiveSession=c1')
self.assertRegex(out, 'Sessions=c1')

out = subprocess.check_output(['loginctl', 'list-users'],
universal_newlines=True)
self.assertRegex(out, '^ +500 +joe +$')
self.assertRegex(out, '(^|\n) +500 +joe +($|\n)')

# note, this does an actual getpwnam() in the client, so we cannot call
# this with hardcoded user names; get from actual user in the system
Expand Down

0 comments on commit 39a807c

Please sign in to comment.