def test_i_credential_format(): with pytest.raises(exceptions.Pyourls3ParamError): client.Yourls("http://example.com", key=123456789) with pytest.raises(exceptions.Pyourls3ParamError): client.Yourls("http://example.com", user="******", passwd=12345) with pytest.raises(exceptions.Pyourls3ParamError): client.Yourls("http://example.com", user=12345)
def instance(): c = client.Yourls(tests.sharevar.standard_url, key="12345") yield c tests.sharevar.modifier = None
def test_i_url_exists(): with pytest.raises(exceptions.Pyourls3ParamError): client.Yourls("")
def test_i_creds_correct(): tests.sharevar.modifier = "badauth" with pytest.raises(exceptions.Pyourls3APIError): client.Yourls(tests.sharevar.standard_url, key="12345") tests.sharevar.modifier = None
def test_i_user_agent(): inst = client.Yourls("http://example.com", key="1234") assert "user-agent" in inst.session.headers.update
def test_i_api_key(): client.Yourls("http://example.com", key="123456789")
def test_i_user_passwd(): client.Yourls("http://example.com", user="******", passwd="password")
def test_i_credentials_present(): with pytest.raises(exceptions.Pyourls3ParamError): client.Yourls("http://example.com")
def test_i_url_formatting(): url = "https://example.com" c = client.Yourls(url, key="12345") assert c.api_endpoint != url + "yourls-api.php" assert c.api_endpoint == url + "/yourls-api.php"
def test_i_url_schema(): with pytest.raises(exceptions.Pyourls3ParamError): client.Yourls("example.com")