/
test_operations.py
37 lines (28 loc) · 1.22 KB
/
test_operations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from tests.testcases import TestCaseUsingRealAPI
from vortexasdk import Products, Geographies, Corporations, Vessels
endpoints_and_searchterms = [
(Products(), "Gasoil"),
(Geographies(), "China"),
(Corporations(), "Oil"),
(Vessels(), "Ocean"),
]
class TestSearchReal(TestCaseUsingRealAPI):
def test_search_exact_match_yields_fewer_results_than_non_exact_match(
self,
):
for endpoint, term in endpoints_and_searchterms:
result_loose_match = endpoint.search(
term=term, exact_term_match=False
)
result_exact_match = endpoint.search(
term=term, exact_term_match=True
)
assert len(result_exact_match) < len(result_loose_match)
def test_search_exact_match_yields_exact_matches_only(self):
for endpoint, term in endpoints_and_searchterms:
result_exact_match = endpoint.search(
term=term, exact_term_match=True
)
actual_names = {e["name"] for e in result_exact_match}
# result must be the exact term, or must contain no results if there's no reference objects with that names
assert actual_names == {term} or actual_names == set()