Esempio n. 1
0
def test_create_repos_incomplete_yaml():
    parsed_args = gh2gl.parse_args(
        ['tests/data/incomplete_config.yaml', '--apitoken', 'test1234'])
    assert_raises(KeyError, gh2gl.createrepos, parsed_args)
    parsed_args = gh2gl.parse_args(
        ['tests/data/incomplete_config_2.yaml', '--apitoken', 'test1234'])
    assert_raises(KeyError, gh2gl.createrepos, parsed_args)
    parsed_args = gh2gl.parse_args(
        ['tests/data/incomplete_config_3.yaml', '--apitoken', 'test1234'])
    assert_raises(TypeError, gh2gl.createrepos, parsed_args)
Esempio n. 2
0
def test_argument_parsing():
    # Successful parse
    parsed_args = gh2gl.parse_args(
        ['no_config.yaml', '--apitoken', 'test1234'])
    assert parsed_args.apitoken == 'test1234'
    assert parsed_args.config == 'no_config.yaml'
    parsed_args = gh2gl.parse_args(['no_config.yaml'])
    assert parsed_args.config == 'no_config.yaml'
    assert parsed_args.apitoken == None
    # Errors detected
    assert_raises(BaseException, gh2gl.parse_args, ['--apitoken', 'test1234'])
    assert_raises(BaseException, gh2gl.parse_args, [])
Esempio n. 3
0
def test_create_repos_success():
    parsed_args = gh2gl.parse_args(
        ['tests/data/test_config.yaml', '--apitoken', 'test1234'])
    # Mock a successful HTTP Response
    with requests_mock.mock() as mock:
        mock.post('http://1.2.3.4.5/api/v3/projects', text='success')
        gh2gl.createrepos(parsed_args)
Esempio n. 4
0
def test_create_repos_timeout():
    parsed_args = gh2gl.parse_args(
        ['tests/data/test_config.yaml', '--apitoken', 'test1234'])
    assert_raises(requests.ConnectionError, gh2gl.createrepos, parsed_args)
Esempio n. 5
0
def test_create_repos_invalid_gitlab_id():
    parsed_args = gh2gl.parse_args(
        ['tests/data/invalid_config_2.yaml', '--apitoken', 'test1234'])
    assert_raises(ValueError, gh2gl.createrepos, parsed_args)
Esempio n. 6
0
def test_create_repos_invalid_yaml():
    parsed_args = gh2gl.parse_args(
        ['tests/data/invalid_yaml.yaml', '--apitoken', 'test1234'])
    assert_raises(AttributeError, gh2gl.createrepos, parsed_args)
Esempio n. 7
0
def test_create_repos_no_file_exists():
    parsed_args = gh2gl.parse_args(
        ['no_config.yaml', '--apitoken', 'test1234'])
    assert_raises(IOError, gh2gl.createrepos, parsed_args)
Esempio n. 8
0
def test_create_repos_invalid_token():
    parsed_args = gh2gl.parse_args(['no_config.yaml'])
    # Mock environment to ensure no Token is set
    with patch.dict('os.environ'):
        assert_raises(KeyError, gh2gl.createrepos, parsed_args)