Skip to content

Commit

Permalink
Fix tests py37 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-mois committed Feb 22, 2022
1 parent 37857a2 commit a77be2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,24 @@ def test_create_tasks(self, toloka_client_mock, tasks_mock, tasks_creation_resul
)
toloka_client_mock.create_tasks.assert_called()
call = toloka_client_mock.create_tasks.mock_calls[0]
assert (tasks_mock,) == call.args, call.args
assert kwargs == call.kwargs, call.kwargs
assert (tasks_mock,) == call[1], call[1]
assert kwargs == call[2], call[2]

def test_create_tasks_with_pool(self, toloka_client_mock, tasks_mock, tasks_creation_result, pool_mock):
assert tasks_creation_result == create_tasks.run(
[task.unstructure() for task in tasks_mock],
pool_id=pool_mock,
)
call = toloka_client_mock.create_tasks.mock_calls[0]
assert all(task.pool_id == pool_mock.id for task in call.args[0])
assert all(task.pool_id == pool_mock.id for task in call[1][0])

def test_create_tasks_with_exam_pool(self, toloka_client_mock, tasks_mock, tasks_creation_result, training_mock):
assert tasks_creation_result == create_tasks.run(
[task.unstructure() for task in tasks_mock],
pool_id=training_mock,
)
call = toloka_client_mock.create_tasks.mock_calls[0]
assert all(task.pool_id == training_mock.id for task in call.args[0])
assert all(task.pool_id == training_mock.id for task in call[1][0])


class TestOpenPool:
Expand All @@ -201,29 +201,29 @@ def test_open_exam_pool_by_id(self, toloka_client_mock, training_mock):
class TestGetAssignments:
def test_get_assignments_by_pool_object(self, toloka_client_mock, pool_mock, assignments_mock):
assert assignments_mock == get_assignments.run(pool_mock)
assert pool_mock.id == toloka_client_mock.get_assignments.mock_calls[0].kwargs['pool_id']
assert pool_mock.id == toloka_client_mock.get_assignments.mock_calls[0][2]['pool_id']

def test_get_assignments_by_pool_id(self, toloka_client_mock, pool_mock, assignments_mock):
assert assignments_mock == get_assignments.run(pool_mock.id)

def test_get_assignments_with_status(self, toloka_client_mock, pool_mock, assignments_mock):
assert assignments_mock == get_assignments.run(pool_mock.id, ['ACCEPTED'])
assert ['ACCEPTED'] == toloka_client_mock.get_assignments.mock_calls[0].kwargs['status']
assert ['ACCEPTED'] == toloka_client_mock.get_assignments.mock_calls[0][2]['status']


class TestGetAssignmentsDf:
def test_get_assignments_df_by_pool_object(self, toloka_client_mock, pool_mock, assignments_df_mock):
assert assignments_df_mock.equals(get_assignments_df.run(pool_mock))
assert pool_mock.id == toloka_client_mock.get_assignments_df.mock_calls[0].kwargs['pool_id']
assert [] == toloka_client_mock.get_assignments_df.mock_calls[0].kwargs['status']
assert 'field' not in toloka_client_mock.get_assignments_df.mock_calls[0].kwargs
assert pool_mock.id == toloka_client_mock.get_assignments_df.mock_calls[0][2]['pool_id']
assert [] == toloka_client_mock.get_assignments_df.mock_calls[0][2]['status']
assert 'field' not in toloka_client_mock.get_assignments_df.mock_calls[0][2]

def test_get_assignments_df_by_pool_id(self, toloka_client_mock, pool_mock, assignments_df_mock):
assert assignments_df_mock.equals(get_assignments_df.run(pool_mock.id))

def test_get_assignments_df_with_status(self, toloka_client_mock, pool_mock, assignments_df_mock):
assert assignments_df_mock.equals(get_assignments_df.run(pool_mock.id, 'APPROVED'))
assert ['APPROVED'] == toloka_client_mock.get_assignments_df.mock_calls[0].kwargs['status']
assert ['APPROVED'] == toloka_client_mock.get_assignments_df.mock_calls[0][2]['status']

def test_get_assignments_df_with_kwargs(self, toloka_client_mock, pool_mock, assignments_df_mock):
kwargs = {'status': ['APPROVED'],
Expand All @@ -232,4 +232,4 @@ def test_get_assignments_df_with_kwargs(self, toloka_client_mock, pool_mock, ass
'exclude_banned': True,
'field': GetAssignmentsTsvParameters.Field.ASSIGNMENT_ID}
assert assignments_df_mock.equals(get_assignments_df.run(pool_mock.id, **kwargs))
assert {'pool_id': pool_mock.id, **kwargs} == toloka_client_mock.get_assignments_df.mock_calls[0].kwargs
assert {'pool_id': pool_mock.id, **kwargs} == toloka_client_mock.get_assignments_df.mock_calls[0][2]
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def some_func(arg, logger):
some_func('info-arg')

assert 1 == len(logger_mock.mock_calls), logger_mock.mock_calls
assert ('info-arg',) == logger_mock.mock_calls[0].args
assert ('info-arg',) == logger_mock.mock_calls[0][1]

0 comments on commit a77be2c

Please sign in to comment.