def test_bogus_user(rando): with raises(FrameworkError, match='Daemon user'): env = ext_daemon.Environment(user='******' % rando) # reset env = ext_daemon.Environment() env.switch()
def test_bogus_group(rando): with raises(FrameworkError, match='Daemon group'): env = ext_daemon.Environment(group='cement_test_group%s' % rando) # reset env = ext_daemon.Environment() env.switch()
def test_pid_exists(tmp): with raises(FrameworkError, match="Process already running"): env = ext_daemon.Environment(pid_file=tmp.file) env.switch() # reset env = ext_daemon.Environment() env.switch()
def test_switch_with_pid(tmp): os.remove(tmp.file) env = ext_daemon.Environment(pid_file=tmp.file) env.switch() assert os.path.exists(tmp.file) # reset env = ext_daemon.Environment() env.switch()
def test_bogus_group(self): rand = random() try: env = ext_daemon.Environment(group='cement_test_group%s' % rand) except exc.FrameworkError as e: self.ok(e.msg.startswith('Daemon group')) raise finally: env = ext_daemon.Environment() env.switch()
def test_pid_exists(self): env = ext_daemon.Environment(pid_file=self.tmp_file) env.switch() try: self.ok(os.path.exists(self.tmp_file)) except exc.FrameworkError as e: self.ok(e.msg.startswith('Process already running')) raise finally: env = ext_daemon.Environment() env.switch()
def test_switch_with_pid(self): (_, tmpfile) = tempfile.mkstemp() os.remove(tmpfile) env = ext_daemon.Environment(pid_file=tmpfile) env.switch() try: self.ok(os.path.exists(tmpfile)) finally: os.remove(tmpfile)
def test_switch(set_uid, set_gid, chdir): assert not set_gid.called assert not chdir.called env = ext_daemon.Environment() env.user = FakeUser() env.group = FakeGroup() env.switch() set_uid.assert_called_once_with('BogusId') set_gid.assert_called_once_with('BogusGroupId') assert chdir.called
def test_switch(self): env = ext_daemon.Environment() env.switch()
def test_switch_with_pid(self): os.remove(self.tmp_file) env = ext_daemon.Environment(pid_file=self.tmp_file) env.switch() self.ok(os.path.exists(self.tmp_file))