示例#1
0
def test_get_args_fail():
    tests = [
        ['updown_service'],
        ['updown_service', 'myservice.name'],
        ['updown_service', 'myservice', 'up'],
        ['updown_service', 'myservice.name', 'wibble'],
    ]

    for argv in tests:
        with mock.patch('sys.argv', argv):
            with pytest.raises(SystemExit) as excinfo:
                updown_service.get_args()
            assert str(excinfo.value) == '2', argv
示例#2
0
def test_get_args_fail():
    tests = [
        ['updown_service'],
        ['updown_service', 'myservice.name'],
        ['updown_service', 'myservice', 'up'],
        ['updown_service', 'myservice.name', 'wibble'],
    ]

    for argv in tests:
        with mock.patch('sys.argv', argv):
            with pytest.raises(SystemExit) as excinfo:
                updown_service.get_args()
            assert str(excinfo.value) == '2', argv
示例#3
0
def test_get_args_pass():
    tests = [
        [['updown_service', 'myservice.name', 'up'], 'up', None, 300, False,
         None],
        [['updown_service', 'myservice.name', 'down'], 'down', None, 300,
         False, None],
        [['updown_service', 'myservice.name', 'down', '-t', '42'], 'down', 42,
         42, False, None],
        [['updown_service', 'myservice.name', 'down', '-x'], 'down', None, 300,
         True, None],
        [['updown_service', 'myservice.name:1234', 'down', '-x'], 'down', None,
         300, True, 1234],
    ]

    for test in tests:
        (argv, expected_state, expected_args_timeout, expected_timeout,
         expected_wait_only, expected_port) = test

        with mock.patch('sys.argv', argv):
            args = updown_service.get_args()
            timeout = updown_service._get_timeout_s(args.service, args.timeout)

        assert args.service == 'myservice.name'
        assert args.state == expected_state
        assert args.timeout == expected_args_timeout
        assert timeout == expected_timeout
        assert args.wait_only == expected_wait_only
        assert args.port == expected_port
def test_get_args_pass():
    tests = [
        [['updown_service', 'myservice.name', 'up'], 'up', None, 300],
        [['updown_service', 'myservice.name', 'down'], 'down', None, 300],
        [['updown_service', 'myservice.name', 'down', '-t', '42'], 'down', 42, 42],
    ]

    for test in tests:
        argv, expected_state, expected_args_timeout, expected_timeout = test

        with mock.patch('sys.argv', argv):
            args = updown_service.get_args()
            timeout = updown_service._get_timeout_s(args.service, args.timeout)

        assert args.service == 'myservice.name'
        assert args.state == expected_state
        assert args.timeout == expected_args_timeout
        assert timeout == expected_timeout
def test_get_args_pass():
    tests = [
        [['updown_service', 'myservice.name', 'up'], 'up', None, 300],
        [['updown_service', 'myservice.name', 'down'], 'down', None, 300],
        [['updown_service', 'myservice.name', 'down', '-t', '42'], 'down', 42,
         42],
    ]

    for test in tests:
        argv, expected_state, expected_args_timeout, expected_timeout = test

        with mock.patch('sys.argv', argv):
            args = updown_service.get_args()
            timeout = updown_service._get_timeout_s(args.service, args.timeout)

        assert args.service == 'myservice.name'
        assert args.state == expected_state
        assert args.timeout == expected_args_timeout
        assert timeout == expected_timeout