def test_incorrect_input_data_missing_description(HttpMock): api_key = get_random_md5() content = """<?xml version="1.0" encoding="utf-8"?> <memberaccount> <error> <code>2</code> </error> </memberaccount>""" http = build_http_mock(HttpMock, content=content) client = harvestmedia.api.client.Client(api_key=api_key) libraries = Library.get_libraries(client)
def test_invalid_token(HttpMock): api_key = get_random_md5() content = """<?xml version="1.0" encoding="utf-8"?> <memberaccount> <error> <code>5</code> <description>Invalid Token</description> </error> </memberaccount>""" http = build_http_mock(HttpMock, content=content) client = harvestmedia.api.client.Client(api_key=api_key) libraries = Library.get_libraries(client)
def test_invalid_remote_token(HttpMock): api_key = get_random_md5() expiry = datetime.datetime.now() expiry += datetime.timedelta(hours=22) # offset for HM timezone test_token = get_random_md5() return_values = [ (200, """<?xml version="1.0" encoding="utf-8"?> <responseservicetoken> <token value="%s" expiry="%s"/> </responseservicetoken>""" % \ (test_token, expiry.strftime("%Y-%m-%dT%H:%M:%S"))), (200, """<memberaccount> <error> <code>5</code> <description>Invalid Token</description> </error> </memberaccount>"""), ] http = build_http_mock(HttpMock, responses=return_values) client = harvestmedia.api.client.Client(api_key=api_key) libraries = Library.get_libraries(client)