def test_createDatabaseConnectMode(mocked_requests): __woqlClient__ = WOQLClient(server="http://localhost:6363", key='mykey') print('__woqlClient__', __woqlClient__.conConfig.serverURL) __woqlClient__.connect() requests.get.assert_called_once_with( 'http://localhost:6363/', headers={'Authorization': 'Basic Om15a2V5'})
def test_Connection(mocked_requests, monkeypatch): __woqlClient__ = WOQLClient() __woqlClient__.connect("http://localhost:6363", 'mykey') with open('tests/connectionDictionary.json') as json_file: dictTest = json.load(json_file) monkeypatch.setattr(__woqlClient__.conCapabilities, "connection", dictTest) assert (dictTest == __woqlClient__.conCapabilities.connection) == True
def test_deleteDatabase(mocked_requests, mocked_requests2, monkeypatch): __woqlClient__ = WOQLClient(server="http://localhost:6363", key="mykey") __woqlClient__.connect() monkeypatch.setattr(__woqlClient__.conCapabilities, "capabilitiesPermit", mock_func_with_1arg) monkeypatch.setattr(__woqlClient__.conCapabilities, "removeDB", mock_func_no_arg) __woqlClient__.deleteDatabase("myFirstTerminusDB") requests.delete.assert_called_once_with( 'http://localhost:6363/myFirstTerminusDB', headers={'Authorization': 'Basic Om15a2V5'})
def test_getSchema(mocked_requests, monkeypatch): __woqlClient__ = WOQLClient(server="http://localhost:6363", key="mykey", db='myFirstTerminusDB') __woqlClient__.connect() #getSchema with no parameter monkeypatch.setattr(__woqlClient__.conCapabilities, "capabilitiesPermit", mock_func_with_1arg) __woqlClient__.getSchema() requests.get.assert_called_with( 'http://localhost:6363/myFirstTerminusDB/schema?terminus%3Aencoding=terminus%3Aturtle', headers={'Authorization': 'Basic Om15a2V5'})
print("read types from csv and construct WOQL objects") types = pd.read_csv("all-layers-types.csv") types["WOQLObject"] = types.apply(construct_objects, axis=1) print("read perperties from csv and construct WOQL objects") properties = pd.read_csv("all-layers-properties.csv") properties["WOQLObject"] = properties.apply(construct_objects, axis=1) print("create Domain and Range object for properties") properties["WOQLObject_DR"] = properties.apply(construct_prop_dr, axis=1) print("create types addon") types["addon"] = types.apply(construct_type_addon, axis=1, type_id=types.id) print("create properties addon") properties["addon"] = properties.apply(construct_property_addon, axis=1, type_id=types.id) print("create db and schema") client = WOQLClient() client.connect(server_url, key) client.deleteDatabase(dbId) client.createDatabase(dbId, "Schema.org") create_schema_from_queries(client, list(types["WOQLObject"])) create_schema_from_queries(client, list(properties["WOQLObject"])) create_schema_from_addon(client, list(properties["WOQLObject_DR"])) create_schema_from_addon(client, list(types["addon"])) create_schema_from_addon(client, list(properties["addon"]))