Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniocarlon committed Aug 24, 2020
1 parent 214a79c commit 4c8a751
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/unit/io/test_carto.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,40 @@ def me_data(self):
table_name = '__table_name__'
cm_mock = mocker.patch.object(ContextManager, 'copy_from')
cm_mock.return_value = table_name

df = GeoDataFrame({'geometry': [Point([0, 0])]})

# When
# Then
with pytest.raises(CartoException):
to_carto(df, table_name, NoQuotaCredentials('fake_user', 'fake_api_key'))


def test_to_carto_quota_warning_skip(mocker):
class NoQuotaCredentials(Credentials):
@property
def me_data(self):
return {
'user_data': {
'remaining_byte_quota': 0
}
}

# Given
table_name = '__table_name__'
cm_mock = mocker.patch.object(ContextManager, 'copy_from')
cm_mock.return_value = table_name
df = GeoDataFrame({'geometry': [Point([0, 0])]})

# When
norm_table_name = to_carto(df, table_name, NoQuotaCredentials('fake_user', 'fake_api_key'),
skip_quota_warning=True)

# Then
assert cm_mock.call_args[0][1] == table_name
assert cm_mock.call_args[0][2] == 'fail'
assert cm_mock.call_args[0][3] is True
assert norm_table_name == table_name


def test_to_carto_chunks(mocker):
# Given
table_name = '__table_name__'
Expand Down

0 comments on commit 4c8a751

Please sign in to comment.