def test_location_class(mocked_timeline, test_id, country, country_code,
                        province, latitude, longitude, confirmed_latest,
                        deaths_latest, recovered_latest):

    # id, country, province, coordinates, confirmed, deaths, recovered
    coordinate = coordinates.Coordinates(latitude=latitude,
                                         longitude=longitude)
    confirmed = timeline.Timeline(confirmed_latest)
    deaths = timeline.Timeline(deaths_latest)
    recovered = timeline.Timeline(recovered_latest)

    location_obj = location.Location(test_id, country, province, coordinate,
                                     confirmed, deaths, recovered)

    assert location_obj.country_code == country_code

    #validate serialize
    check_dict = {
        'id': test_id,
        'country': country,
        'province': province,
        'country_code': country_code,
        'coordinates': {
            'latitude': latitude,
            'longitude': longitude
        },
        'latest': {
            'confirmed': confirmed_latest,
            'deaths': deaths_latest,
            'recovered': recovered_latest
        }
    }

    assert location_obj.serialize() == check_dict
def test_location_class(mocked_timeline, test_id, country, country_code,
                        country_population, province, latitude, longitude,
                        confirmed_latest, deaths_latest, recovered_latest):

    # id, country, province, coordinates, confirmed, deaths, recovered
    coords = coordinates.Coordinates(latitude=latitude, longitude=longitude)

    # Timelines
    confirmed = timeline.Timeline(confirmed_latest)
    deaths = timeline.Timeline(deaths_latest)
    recovered = timeline.Timeline(recovered_latest)

    # Date now.
    now = datetime.utcnow().isoformat() + 'Z'

    # Location.
    location_obj = location.TimelinedLocation(test_id, country, province,
                                              coords, now, {
                                                  'confirmed': confirmed,
                                                  'deaths': deaths,
                                                  'recovered': recovered,
                                              })

    assert location_obj.country_code == country_code
    assert not location_obj.serialize() == None
Example #3
0
def test_coordinates_class(latitude, longitude):
    coord_obj = coordinates.Coordinates(latitude=latitude, longitude=longitude)

    #validate serialize
    check_obj = {'latitude': latitude, 'longitude': longitude}

    assert coord_obj.serialize() == check_obj
Example #4
0
def test_location_class(mocked_timeline, test_id, country, country_code,
                        province, latitude, longitude, confirmed_latest,
                        deaths_latest, recovered_latest):

    # id, country, province, coordinates, confirmed, deaths, recovered
    coords = coordinates.Coordinates(latitude=latitude, longitude=longitude)

    # Timelines
    confirmed = timeline.Timeline(confirmed_latest)
    deaths = timeline.Timeline(deaths_latest)
    recovered = timeline.Timeline(recovered_latest)

    # Date now.
    now = datetime.utcnow().isoformat() + 'Z'

    # Location.
    location_obj = location.TimelinedLocation(test_id, country, province,
                                              coords, now, {
                                                  'confirmed': confirmed,
                                                  'deaths': deaths,
                                                  'recovered': recovered,
                                              })

    assert location_obj.country_code == country_code

    #validate serialize
    check_dict = {
        'id': test_id,
        'country': country,
        'country_code': country_code,
        'province': province,
        'last_updated': now,
        'coordinates': {
            'latitude': latitude,
            'longitude': longitude
        },
        'latest': {
            'confirmed': confirmed_latest,
            'deaths': deaths_latest,
            'recovered': recovered_latest
        }
    }

    assert location_obj.serialize() == check_dict
def test_location_class(
    mocked_timeline,
    test_id,
    country,
    country_code,
    province,
    latitude,
    longitude,
    confirmed_latest,
    deaths_latest,
    recovered_latest,
):
    # id, country, province, coordinates, confirmed, deaths, recovered
    coords = coordinates.Coordinates(latitude=latitude, longitude=longitude)

    # Timelines
    confirmed = models.Timeline(confirmed_latest)
    deaths = models.Timeline(deaths_latest)
    recovered = models.Timeline(recovered_latest)

    # Date now.
    now = datetime.utcnow().isoformat() + "Z"

    # Location.
    location_obj = location.TimelinedLocation(
        test_id,
        country,
        province,
        coords,
        now,
        {
            "confirmed": confirmed,
            "deaths": deaths,
            "recovered": recovered,
        },
    )

    assert location_obj.country_code == country_code
    assert location_obj.serialize() is not None