'Test detect location info using freegeoip.'

@requests_mock.Mocker()
@patch('homeassistant.util.location._get_freegeoip', return_value=None)
def test_detect_location_info_ipapi(self, mock_req, mock_freegeoip):

    mock_req.get(location_util.IP_API, text=load_fixture('ip-api.com.json'))
    info = location_util.detect_location_info(_test_real=True)
    assert (info is not None)
    assert (info.ip == '1.2.3.4')
    assert (info.country_code == 'US')
    assert (info.country_name == 'United    States')
    assert (info.region_code == 'CA')
    assert (info.region_name == 'California')
    assert (info.city == 'San    Diego')
    assert (info.zip_code == '92122')
    assert (info.time_zone == 'America/Los_Angeles')
    assert (info.latitude == 32.8594)
    assert (info.longitude == (-117.2073))
    assert (not info.use_metric)
