예제 #1
0
def test_build_url():
    full_url = build_url('insult', 'txt', language_code='en', who='Kristen', plural=True)
    expected_url = 'https://insult.mattbas.org/api/en/insult.txt?who=Kristen&plural=on'
    assert full_url == expected_url, "Should be '{}".format(expected_url)
예제 #2
0
def test_build_url_invalid_who():
    with pytest.raises(ValueError):
        build_url('insult', 'json', language_code='en', who=7, plural=False)
예제 #3
0
def test_build_url_invalid_plural():
    with pytest.raises(ValueError):
        build_url('insult', 'json', language_code='en', who='Mace Windu', plural='invalid')
예제 #4
0
def test_build_url_invalid_language_code():
    with pytest.raises(ValueError):
        build_url('insult', 'json', language_code=3, who='The Avengers', plural=True)
예제 #5
0
def test_build_url_no_response_format():
    with pytest.raises(ValueError):
        build_url('insult', '', language_code='en', who='Beyonce', plural=False)
예제 #6
0
def test_build_url_invalid_response_format():
    with pytest.raises(ValueError):
        build_url('insult', 'invalid', language_code='en', who='Wakanda', plural=False)
예제 #7
0
def test_build_url_no_request_type():
    with pytest.raises(ValueError):
        build_url('', 'txt', language_code='en', who='Kristen', plural=False)
예제 #8
0
def test_build_url_invalid_request_type():
    with pytest.raises(ValueError):
        build_url('invalid', 'txt', language_code='en', who='Campbell', plural=False)