def with_missing_tld(): expect(URL(URL_NO_TLD).errors) == [ "Unable to connect to domain.", "URL responded with a non-successful status code: (no response)", ]
def with_non_url(): expect(URL(NON_URL).errors) == [ "Invalid URL 'example': No schema supplied. Perhaps you meant http://example?", "URL responded with a non-successful status code: (no response)", ]
def with_invalid_scheme(): expect(URL(URL_BAD_SCHEME).errors) == [ "No connection adapters were found for 'foobar://example.com'", "URL responded with a non-successful status code: (no response)", ]
def with_missing_scheme(): expect(URL(URL_NO_SCHEME).errors) == [ "Invalid URL 'example.com': No schema supplied. Perhaps you meant http://example.com?", "URL responded with a non-successful status code: (no response)", ]
def with_unsuccessful_status_code(): expect(URL(URL_404).errors) == [ "URL responded with a non-successful status code: 404", ]
def with_valid_url(): expect(URL(URL_200).errors) == []
def is_based_on_valid_url_and_success_status(url, valid): expect(URL(url).valid) == valid
def is_none_with_invalid_url(): expect(URL(URL_BAD_SCHEME).status_code) == None
def is_based_on_response_status_code(url, valid): expect(URL(url).status_code) == valid