Skip to content

Commit 97f733b

Browse files
committed
GH-17: Create test cases for the primary usage flows
1 parent 23e591f commit 97f733b

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def source_1():
6+
return {
7+
"Rapid Wien - First Vienna": {"id": "RapidWien_FirstVienna", "w1": 1.93, "x": 2.32, "w2": 7.44},
8+
"Al Bourj - Al Nejmeh": {"id": "Bourj_Nejmeh", "w1": 26, "x": 11.5, "w2": 1.05},
9+
}
10+
11+
12+
@pytest.fixture
13+
def source_2():
14+
return {
15+
"Bourj FC - Nejmeh SC Beirut": {"id": "Bourj_Nejmeh", "w1": 32, "x": 12, "w2": 1.05},
16+
"SK Rapid Wien - First Vienna FC": {"id": "RapidWien_FirstVienna", "w1": 1.97, "x": 2.3, "w2": 8.2},
17+
}

tests/test_map.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
1-
def test_a():
2-
assert True
1+
from fuzzymap import FuzzyMap
2+
3+
4+
def test_basic_usage_1(source_1, source_2):
5+
"""Mapping in source_2 using source_1 keys."""
6+
source_2 = FuzzyMap(source_2)
7+
for game, odds in source_1.items():
8+
assert source_2[game].get("id") == odds.get("id")
9+
10+
11+
def test_basic_usage_2(source_1, source_2):
12+
"""Mapping in source_1 using source_2 keys."""
13+
source_1 = FuzzyMap(source_1)
14+
for game, odds in source_2.items():
15+
assert source_1[game].get("id") == odds.get("id")
16+
17+
18+
def test_not_matching_key_case(source_1):
19+
"""It should not match a key that does not satisfy the ratio."""
20+
source_1 = FuzzyMap(source_1)
21+
assert source_1["Some Dummy Key"] is None
22+
23+
24+
def test_with_a_custom_ratio(source_1):
25+
"""A dummy key should match for a small ratio."""
26+
source_1 = FuzzyMap(source_1)
27+
source_1.ratio = 24 # decreasing the ratio
28+
assert source_1["Some Dummy Key"] is not None

0 commit comments

Comments
 (0)