Skip to content

Commit 9b09791

Browse files
authored
Merge pull request #63 from DrGFreeman/62-fix-ci-moto
Fix failing CI by replacing deprecated moto mock_dynamodb2
2 parents a6147d5 + 75bab12 commit 9b09791

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: requirements-txt-fixer
1111

1212
- repo: https://github.com/psf/black
13-
rev: 19.10b0
13+
rev: 22.3.0
1414
hooks:
1515
- id: black
1616

dynamo_pandas/dynamo_pandas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def put_df(df, *, table, boto3_kwargs={}):
216216

217217

218218
def _to_df(items, *, dtype=None):
219-
"""Convert an item dictionary or list of item dictionaries into a pandas DataFrame.
220-
"""
219+
"""Convert an item dictionary or list of item dictionaries into a pandas
220+
DataFrame."""
221221
if isinstance(items, dict):
222222
items = [items]
223223

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
import boto3
5-
from moto import mock_dynamodb2
5+
from moto import mock_dynamodb
66
import pytest
77
from test_data import large_table_items
88
from test_data import test_df
@@ -23,7 +23,7 @@ def aws_credentials():
2323
@pytest.fixture()
2424
def ddb_client(aws_credentials):
2525
"""Fixture to mock the dynamodb client using moto."""
26-
with mock_dynamodb2():
26+
with mock_dynamodb():
2727
yield boto3.client("dynamodb")
2828

2929

tests/test_main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def test_no_keys(self, test_df_table):
8888
)
8989

9090
def test_keys(self, test_df_table):
91-
""""Test with keys specified. Also test that keys not in the table are ignored.
92-
"""
91+
"""Test with keys specified. Also test that keys not in the table are
92+
ignored."""
9393
df = get_df(table=test_df_table, keys=[{"id": 0}, {"id": 2}, {"id": 3}])
9494

9595
assert {c: t.name for c, t in zip(df.columns, df.dtypes)} == {
@@ -207,7 +207,9 @@ def test_boto3_kwargs_are_passed(self, ddb_client, test_df_table, keys):
207207

208208
# With the correct region we expect to get the items.
209209
df = get_df(
210-
keys=keys, table=test_df_table, boto3_kwargs=dict(region_name="us-east-1"),
210+
keys=keys,
211+
table=test_df_table,
212+
boto3_kwargs=dict(region_name="us-east-1"),
211213
)
212214
assert not df.empty
213215

tests/test_transactions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def test_from_df_types(self, ddb_client, empty_table, column, id, expected):
7373
assert resp["Item"] == expected
7474

7575
def test_existing_key_overwrites(self, ddb_client, empty_table):
76-
"""Test that putting an item for which the key already exists overwrites the item.
77-
"""
76+
"""Test that putting an item for which the key already exists overwrites the
77+
item."""
7878
put_item(item=dict(id=0, A=0, B=1), table=empty_table)
7979

8080
put_item(item=dict(id=0, A="abc"), table=empty_table)
@@ -421,7 +421,8 @@ def test_boto3_kwargs_are_passed(self, ddb_client, test_df_table):
421421

422422
# With the correct region we expect to get the items.
423423
items = get_all_items(
424-
table=test_df_table, boto3_kwargs=dict(region_name="us-east-1"),
424+
table=test_df_table,
425+
boto3_kwargs=dict(region_name="us-east-1"),
425426
)
426427
assert items
427428

0 commit comments

Comments
 (0)