Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed May 7, 2024
1 parent 533b72a commit bea8f2d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
certifi==2024.2.2
charset-normalizer==3.3.2
coverage==7.5.1
dnspython==2.6.1
idna==3.7
iniconfig==2.0.0
mypy==1.10.0
mypy-extensions==1.0.0
packaging==24.0
pluggy==1.5.0
pymongo==4.7.1
pytest==8.2.0
requests==2.31.0
Transcrypt==3.9.1
typing_extensions==4.11.0
urllib3==2.2.1
47 changes: 47 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pytest
from utils.create_unique_key import create_unique_key


@pytest.mark.parametrize(
"item, key_fields, expected_result",
[
(
{
"_id": {"$oid": "6635f923c113f9ccd1cea039"},
"fuel_type": "Petrol",
"importer_type": "AMD",
"make": "B.M.W.",
"month": "2024-03",
"number": "54",
"vehicle_type": "Sedan",
},
["month"],
"2024-03",
),
],
)
def test_generate_unique_key_for_cars(item, key_fields, expected_result):
assert create_unique_key(item, key_fields) == expected_result


def test_generate_unique_key_for_coe():
assert (
create_unique_key(
{
"_id": {"$oid": "663a4e0a3d609a019b87090e"},
"bidding_no": "2",
"bids_received": "1,008",
"bids_success": "690",
"month": "2024-04",
"premium": "102001",
"quota": "690",
"vehicle_class": "Category B",
},
["month", "bidding_no"],
)
== "2024-04-2"
)


if __name__ == "__main__":
pytest.main()

0 comments on commit bea8f2d

Please sign in to comment.