Example #1
0
def test_sign():
    aries_json = json.loads('''[{ 
        "name": "Aries",
        "famous_people": ["Famous1", "Famous2"],
        "compatibility": ["Leo", "Sagittarius", "Gemini", "Aquarius"],
        "sun_dates": ["March 21", "April 19"]}]''')
    signs = get_signs(aries_json)
    assert (len(signs) == 1)
    assert (type(signs[0]) == Sign)
    assert (signs[0].name == 'Aries')
    assert (signs[0].compatibility == [
        'Leo', 'Sagittarius', 'Gemini', 'Aquarius'
    ])
    assert (signs[0].famous_people == ['Famous1', 'Famous2'])
    assert (signs[0].sun_dates == ['March 21', 'April 19'])

    assert (get_signs([]) == [])
Example #2
0
def signs():
    if not PATH.exists():
        urlretrieve(URL, PATH)
    with open(PATH) as f:
        data = json.loads(f.read())
    return get_signs(data)