Skip to content

Rework a test_query test to use dirty_equals #2166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions tests/mock_vws/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import pytest
import requests
from dirty_equals import IsInstance
from PIL import Image
from tenacity import Retrying
from tenacity.retry import retry_if_exception_type
Expand Down Expand Up @@ -531,18 +532,15 @@

assert_query_success(response=response)
(result,) = response.json()["results"]
assert result.keys() == {"target_id", "target_data"}
assert result["target_id"] == target_id
target_data = result["target_data"]
assert target_data.keys() == {
"application_metadata",
"name",
"target_timestamp",
assert result == {

Check warning on line 535 in tests/mock_vws/test_query.py

View check run for this annotation

Codecov / codecov/patch

tests/mock_vws/test_query.py#L535

Added line #L535 was not covered by tests
"target_id": target_id,
"target_data": {
"application_metadata": metadata_encoded,
"name": name,
"target_timestamp": IsInstance(expected_type=int),
},
}
assert target_data["application_metadata"] == metadata_encoded
assert target_data["name"] == name
target_timestamp = target_data["target_timestamp"]
assert isinstance(target_timestamp, int)
target_timestamp = int(result["target_data"]["target_timestamp"])

Check warning on line 543 in tests/mock_vws/test_query.py

View check run for this annotation

Codecov / codecov/patch

tests/mock_vws/test_query.py#L543

Added line #L543 was not covered by tests
time_difference = abs(approximate_target_created - target_timestamp)
max_time_difference = 5
assert time_difference < max_time_difference
Expand Down