Ejemplo n.º 1
0
def test_lookup():
    API_VERSION_TESTED = 1

    bw = BuiltWith('key')
    HTTPretty.register_uri(HTTPretty.GET, ENDPOINTS_BY_API_VERSION[API_VERSION_TESTED], body='true')

    result = bw.lookup('example.com')

    qs = HTTPretty.last_request.querystring
    assert qs.get('KEY') == ['key']
    assert qs.get('LOOKUP') == ['example.com']
    assert result is True
Ejemplo n.º 2
0
def test_lookup_alternate_version():
    API_VERSION_TESTED = 2

    bw = BuiltWith('key', api_version=API_VERSION_TESTED)
    HTTPretty.register_uri(HTTPretty.GET, ENDPOINTS_BY_API_VERSION[API_VERSION_TESTED],
                           body='{"Paths": []}')

    result = bw.lookup('example.com')

    qs = HTTPretty.last_request.querystring
    assert qs.get('KEY') == ['key']
    assert qs.get('LOOKUP') == ['example.com']
    assert isinstance(result, BuiltWithDomainInfo)
    assert {'Paths': []} == result.api_response_json