示例#1
0
def test_with_malformed_url():
  malformed_urls = (
    '',
    'boom',
    'codecommit:/test_repo',    # missing a slash
    'codecommit//test_repo',    # missing colon
    '://test_repo',             # missing protocol
    'codecommit://',            # missing repository
    'codecommit:://test_repo',  # extra colon
    'codecommit:///test_repo',  # extra slash
  )

  for url in malformed_urls:
    with pytest.raises(FormatError):
      Context.from_url(url)
示例#2
0
def test_with_nonexistant_profile():
  with pytest.raises(ProfileNotFound):
    Context.from_url('codecommit://missing_profile@test_repo')
示例#3
0
def test_with_profile_and_region():
  context = Context.from_url('ca-central-1://profile@test_repo')
  assert 'test_repo' == context.repository
  assert 'v1' == context.version
  assert 'ca-central-1' == context.region
  assert DEFAULT_CREDS == context.credentials
示例#4
0
def test_without_credentials():
  with pytest.raises(CredentialsNotFound):
    Context.from_url('codecommit://test_repo')
示例#5
0
def test_with_profile():
  context = Context.from_url('codecommit://profile@test_repo')
  assert 'test_repo' == context.repository
  assert 'v1' == context.version
  assert 'us-west-2' == context.region
  assert DEFAULT_CREDS == context.credentials
def test_with_invalid_region():
    with pytest.raises(RegionNotAvailable):
        Context.from_url('codecommit://test_repo')
示例#7
0
def test_with_unset_region():
  with pytest.raises(RegionNotFound):
    Context.from_url('codecommit://test_repo')
def test_with_assume_role_provider():
    context = Context.from_url('ca-central-1://profile@test_repo')
    context.session.get_component.assert_called_with('credential_provider')
    assert type(mock_assume_role.cache), botocore.JSONFileCache
def test_with_different_partition():
    context = Context.from_url('us-gov-west-1://profile@repo')
    assert 'repo' == context.repository
    assert 'v1' == context.version
    assert 'us-gov-west-1' == context.region
    assert DEFAULT_CREDS == context.credentials
def test_with_gov_region():
    context = Context.from_url('codecommit://test_repo')
    assert 'test_repo' == context.repository
    assert 'v1' == context.version
    assert 'us-gov-east-1' == context.region
    assert DEFAULT_CREDS == context.credentials
def test_with_github():
    with pytest.raises(FormatError):
        Context.from_url('github://test_repo')
def test_with_bad_region():
    with pytest.raises(RegionNotAvailable):
        Context.from_url('yy-central-1://test_repo')