コード例 #1
0
def test_repo_doesnt_contain_trytravis():
    with pytest.raises(RuntimeError):
        with mock.patch('trytravis.user_input') as mock_input:
            mock_input.side_effect = ['https://github.com/trytravis-target']
            trytravis.config_dir = os.path.dirname(os.path.abspath(__file__))

            trytravis._main(['--repo'])
    assert not os.path.isfile(os.path.join(trytravis.config_dir, 'repo'))
コード例 #2
0
def test_repo_invalid_url():
    with pytest.raises(RuntimeError):
        with mock.patch('trytravis.user_input') as mock_input:
            mock_input.side_effect = [
                'https://www.github.com/testauthor-trytravis', 'y'
            ]
            trytravis.config_dir = os.path.dirname(os.path.abspath(__file__))

            trytravis._main(['--repo'])

    assert not os.path.isfile(os.path.join(trytravis.config_dir, 'repo'))
コード例 #3
0
def test_repo_ssh():
    with mock.patch('trytravis.user_input') as mock_input:
        mock_input.side_effect = ['y']
        trytravis.config_dir = os.path.dirname(os.path.abspath(__file__))

        trytravis._main(
            ['--repo', 'ssh://[email protected]/testauthor/testname-trytravis'])

        assert os.path.isfile(os.path.join(trytravis.config_dir, 'repo'))

        with open(os.path.join(trytravis.config_dir, 'repo'), 'r') as f:
            assert f.read(
            ) == 'ssh://[email protected]/testauthor/testname-trytravis'

        os.remove(os.path.join(trytravis.config_dir, 'repo'))
コード例 #4
0
def test_help():
    trytravis._main(['--help'])
コード例 #5
0
def test_too_many_parameters():
    trytravis._main(['a', 'b', 'c'])