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'))
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'))
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'))
def test_help(): trytravis._main(['--help'])
def test_too_many_parameters(): trytravis._main(['a', 'b', 'c'])