예제 #1
0
def test_runner_no_daemonize():
    from gservice.runner import Runner
    class EmptyRunner(Runner):
        def run(self): pass
    EmptyRunner._args = ['start', '-C', 'config', '-n']
    EmptyRunner._opener = mock_open({"config": "", "serviced.log": "", "serviced.pid": ""})
    with silencer():
        EmptyRunner()
예제 #2
0
def test_extend_file_config_option():
    from gservice.runner import Runner
    from gservice.config import Setting

    class ConfigCheckRunner(Runner):
        foo = Setting('foo')
        def run(self):
            assert self.foo == 'bar2'

    ConfigCheckRunner._args = ['run', '-C', 'config1', '-X', "foo = 'bar2'"]
    ConfigCheckRunner._opener = mock_open({"config1": "foo = 'bar1'"})

    with silencer():
        ConfigCheckRunner().do_action()
예제 #3
0
def test_command_line_override_config():
    """ Test that specifying an option on the command line override any
        value set in a config file"""
    from gservice.runner import Runner

    class ConfigCheckRunner(Runner):
        def run(self):
            assert self.pidfile_path == 'mypidfile.pid'

    ConfigCheckRunner._args = ['run', '-C', 'config', '-p', 'mypidfile.pid']
    ConfigCheckRunner._opener = mock_open({"config": "pidfile = 'configpidfile.pid'"})

    with silencer():
        ConfigCheckRunner().do_action()
예제 #4
0
def test_read_config_option():
    from gservice.runner import Runner
    from gservice.config import Option

    class ConfigCheckRunner(Runner):
        foo = Option('foo')
        def run(self):
            assert self.foo == 'bar'

    ConfigCheckRunner._args = ['run', '-C', 'config']
    ConfigCheckRunner._opener = mock_open({"config": "foo = 'bar'"})

    with silencer():
        ConfigCheckRunner().do_action()
예제 #5
0
def test_command_line_override_config():
    """ Test that specifying an option on the command line override any
        value set in a config file"""
    from gservice.runner import Runner

    class ConfigCheckRunner(Runner):
        def run(self):
            assert self.pidfile_path == 'mypidfile.pid'

    ConfigCheckRunner._args = ['run', '-C', 'config', '-p', 'mypidfile.pid']
    ConfigCheckRunner._opener = mock_open(
        {"config": "pidfile = 'configpidfile.pid'"})

    with silencer():
        ConfigCheckRunner().do_action()
예제 #6
0
def test_read_config_option():
    from gservice.runner import Runner
    from gservice.config import Setting

    class ConfigCheckRunner(Runner):
        foo = Setting('foo')

        def run(self):
            assert self.foo == 'bar'

    ConfigCheckRunner._args = ['run', '-C', 'config']
    ConfigCheckRunner._opener = mock_open({"config": "foo = 'bar'"})

    with silencer():
        ConfigCheckRunner().do_action()
예제 #7
0
def test_runner_no_daemonize():
    from gservice.runner import Runner

    class EmptyRunner(Runner):
        def run(self):
            pass

    EmptyRunner._args = ['start', '-C', 'config', '-n']
    EmptyRunner._opener = mock_open({
        "config": "",
        "serviced.log": "",
        "serviced.pid": ""
    })
    with silencer():
        EmptyRunner()
예제 #8
0
def test_extend_file_config_option():
    from gservice.runner import Runner
    from gservice.config import Setting

    class ConfigCheckRunner(Runner):
        foo = Setting('foo')

        def run(self):
            assert self.foo == 'bar2'

    ConfigCheckRunner._args = ['run', '-C', 'config1', '-X', 'config2']
    ConfigCheckRunner._opener = mock_open({
        "config1": "foo = 'bar1'",
        "config2": "foo = 'bar2'"
    })

    with silencer():
        ConfigCheckRunner().do_action()
예제 #9
0
def test_runner_action_required():
    from gservice.runner import Runner
    Runner._args = []
    with silencer():
        Runner()
예제 #10
0
def test_runner_reads_config():
    from gservice.runner import Runner
    Runner._args = ['start', '-C', 'config']
    Runner._opener = mock_open({"config": "", "serviced.log": ""})
    with silencer():
        Runner()
예제 #11
0
def test_runner_config_required():
    from gservice.runner import Runner
    Runner._args = ['start']
    with silencer():
        Runner()
예제 #12
0
def test_runner_action_required():
    from gservice.runner import Runner
    Runner._args = []
    with silencer():
        Runner()
예제 #13
0
def test_runner_reads_config():
    from gservice.runner import Runner
    Runner._args = ['start', '-C', 'config']
    Runner._opener = mock_open({"config": "", "serviced.log": ""})
    with silencer():
        Runner()
예제 #14
0
def test_runner_config_required():
    from gservice.runner import Runner
    Runner._args = ['start']
    with silencer():
        Runner()