echong-SG / API-python-client-MKilic

MIT License
3 stars 0 forks source link

Add test case for pagination #16

Closed echong-SG closed 3 years ago

echong-SG commented 3 years ago

@mirkan1 can you add this as a test case? Basically confirms the pagination is working.

city = "Philadelphia"
brand = "Starbucks"

brand_search_initial = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 10, after_result_number = 0)
brand_search_pagination1 = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 25, after_result_number = 0)
brand_search_pagination2 = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 25, after_result_number = 10)

set(brand_search_initial.placekey) == set(brand_search_pagination1.placekey).difference(brand_search_pagination2.placekey)
mirkan1 commented 3 years ago

it worked; line 28 on test_search_pagination function test result is True https://github.com/echong-SG/API-python-client-MKilic/commit/b835e0bb0f6b09b460802bbe7f606a51006060c0

BTW below line takes a pretty big-time get a response from safe graph API:

placekeys = [
        "224-222@5vg-7gv-d7q", # "222-222@5qw-shj-7qz", "222-222@5s6-pyc-7qz", "zzy-222@5xc-k8q-zmk",
        "zzw-222@8fy-fjg-b8v", # (Disney World)
        "zzy-227@5sb-8cw-pjv", # (O'Hare Airport)
        "222-223@65y-rxx-djv", # (Walmart in Albany, NY)
        ] 
sgql_client.places(placekeys, columns="*", return_type="pandas")

line 166 on client.py

result = self.client.execute(query, variable_values=params)

takes around 10 to 30 seconds 🧷

echong-SG commented 3 years ago

@mirkan1 noted on the timing - we're looking into that.

Can you add one more test case here? Can you confirm that there is no overlap between the set of placekeys in brand_search_initial and brand_search_pagination1?

city = "Philadelphia"
brand = "Starbucks"

brand_search_initial = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 10, after_result_number = 0)
brand_search_pagination1 = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 10, after_result_number = 10)
mirkan1 commented 3 years ago
    city = "Philadelphia"
    brand = "Starbucks"

    brand_search_initial = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 10, after_result_number = 0)
    brand_search_pagination1 = sgql_client.search(columns = ['placekey'], brand = brand, city = city, max_results = 10, after_result_number = 10)
    for i in range(len(brand_search_initial)):
        assert brand_search_initial.loc[i] != brand_search_pagination1.loc[i]

result True

mirkan1 commented 3 years ago

also in test_client.py