backtrackbaba / cowin

Python wrapper for CoWin API's
MIT License
42 stars 18 forks source link

Final test fails #5

Closed DragonWarrior15 closed 3 years ago

DragonWarrior15 commented 3 years ago

The final test whose code is listed below fails

def test_min_age_limit_filter():
    cowin = CoWinAPI()
    availability = cowin.get_availability_by_district("395", min_age_limt=18)

    assert isinstance(availability, dict)
    assert isinstance(availability.get('centers'), list)
    assert len(availability.get('centers')[0].get('sessions')) == 0

Reason: Date is not specified, hence the results will keep changing daily depending on when the tests are run.

Solution: Pass the date parameter and accordingly correct the final assertion test (based on the readme). The below code passes the tests

def test_min_age_limit_filter():
    cowin = CoWinAPI()
    availability = cowin.get_availability_by_district("395", date="03-05-2021", min_age_limt=18)

    assert isinstance(availability, dict)
    assert isinstance(availability.get('centers'), list)
    assert len(availability.get('centers')[0].get('sessions')) == 2

Also, in the constants file, date format needs to be corrected to be consistent with the API, DD_MM_YYYY = "%d-%m-%y" to DD_MM_YYYY = "%d-%m-%Y".

backtrackbaba commented 3 years ago

Thanks, @DragonWarrior15 for the PR. It was an oversight from my end