Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pachCode committed Jun 20, 2024
1 parent 70e47ac commit 85025d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ flake8==4.0.*
isort==5.10.*
mock==4.0.3
mongomock==4.1.*
moto[server]==5.0.9
moto[server,sqs]==5.0.9
mypy==1.0.1
pytest==7.4.*
pytest-cov==4.1.*
Expand Down
14 changes: 12 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ def aws_credentials() -> None:
def aws_endpoint_urls(
aws_credentials,
) -> Generator[Dict[str, str], None, None]:
sqs = subprocess.Popen(['moto_server', 'sqs', '-p', '4000'])
sqs = subprocess.Popen(
[
'moto_server',
'-p',
'4000',
]
)

endpoints = dict(
sqs='http://127.0.0.1:4000/',
Expand Down Expand Up @@ -222,7 +228,11 @@ async def sqs_client():
session = aiobotocore.session.get_session()
async with session.create_client('sqs', 'us-east-1') as sqs:
await sqs.create_queue(
QueueName='core.fifo', Attributes={'FifoQueue': 'true'}
QueueName='core.fifo',
Attributes={
'FifoQueue': 'true',
'ContentBasedDeduplication': 'true',
},
)
resp = await sqs.get_queue_url(QueueName='core.fifo')
sqs.send_message = partial(sqs.send_message, QueueUrl=resp['QueueUrl'])
Expand Down
8 changes: 4 additions & 4 deletions tests/tasks/test_sqs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def my_task(data: Dict) -> None:
max_retries=3,
)(my_task)()

expected_calls = [call(test_message)] * 4
expected_calls = [call(test_message)] * 3
async_mock_function.assert_has_calls(expected_calls)
assert async_mock_function.call_count == len(expected_calls)

Expand Down Expand Up @@ -380,9 +380,9 @@ async def countdown_tester(data: Dict):
async def test_concurrency_controller(
sqs_client,
) -> None:
message_id = str(uuid.uuid4())
test_message = dict(id=message_id, name='fast-agave')
for i in range(5):
message_id = str(uuid.uuid4())
test_message = dict(id=message_id, name='fast-agave')
await sqs_client.send_message(
MessageBody=json.dumps(test_message),
MessageGroupId=message_id,
Expand All @@ -405,4 +405,4 @@ async def task_counter(data: Dict) -> None:
)(task_counter)()

running_tasks = [call[0] for call, _ in async_mock_function.call_args_list]
assert max(running_tasks) == 2
assert max(running_tasks) == 3

0 comments on commit 85025d1

Please sign in to comment.