diff --git a/cloudbaseinit/osutils/freebsd.py b/cloudbaseinit/osutils/freebsd.py index 49fe91b..48ab7b9 100644 --- a/cloudbaseinit/osutils/freebsd.py +++ b/cloudbaseinit/osutils/freebsd.py @@ -12,8 +12,11 @@ def reboot(self): raise OSError('Reboot failed') def user_exists(self, username): + ''' + :return: bool + ''' try: - subprocess.check_output(["id", username]) + subprocess.check_output(['id', username]) except CalledProcessError: return False return True diff --git a/cloudbaseinit/tests/osutils/test_freebsd.py b/cloudbaseinit/tests/osutils/test_freebsd.py index e34b950..fe95757 100644 --- a/cloudbaseinit/tests/osutils/test_freebsd.py +++ b/cloudbaseinit/tests/osutils/test_freebsd.py @@ -20,3 +20,7 @@ def teardown_method(self, method): def test_reboot(self, system): with raises(OSError): self.bsd.reboot() + + def test_user_exists(self): + assert not self.bsd.user_exists('stranger') + assert self.bsd.user_exists('root')