Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejtonev committed Feb 29, 2024
1 parent ccc752e commit 8451528
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/transformations/loaders/data/address.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_id,street,street_num,city
1,Ilica,2,Zagreb
2,Death Valley,0,Knowhere
3,Horvacanska,3,Horvati
4,Broadway,12,New York
3 changes: 3 additions & 0 deletions tests/transformations/loaders/data/i2a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_id,ind_id,duration
1,2,12
2,1,5
6 changes: 6 additions & 0 deletions tests/transformations/loaders/data/individual.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ind_id,name,surname,add_id
1,Tomislav,Petrov,1
2,Ivan,Horvat,3
3,Marko,Horvat,3
4,John,Doe,2
5,John,Though,4
37 changes: 37 additions & 0 deletions tests/transformations/loaders/test_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,43 @@ def test_local_table_to_graph_importer_csv(memgraph):
importer = CSVLocalFileSystemImporter(path=path, data_configuration=my_configuration, memgraph=memgraph)
importer.translate(drop_database_on_start=True)

conf_with_edge_params = {
"indices": {"address": ["add_id"], "individual": ["ind_id"]},
"name_mappings": {"individual": {"label": "INDIVIDUAL"}, "address": {"label": "ADDRESS"}},
"one_to_many_relations": {
"address": [],
"individual": [
{
"foreign_key": {"column_name": "add_id", "reference_table": "address", "reference_key": "add_id"},
"label": "LIVES_IN",
"parameters": {"p": "this is fixed for all edges"},
}
],
},
}
importer = CSVLocalFileSystemImporter(path=path, data_configuration=conf_with_edge_params, memgraph=memgraph)
importer.translate(drop_database_on_start=True)

conf_with_many_to_many = {
"indices": {"address": ["add_id"], "individual": ["ind_id"]},
"name_mappings": {"individual": {"label": "INDIVIDUAL"}, "address": {"label": "ADDRESS"}},
"one_to_many_relations": {"address": [], "individual": []},
"many_to_many_relations": {
"i2a": {
"foreign_key_from": {
"column_name": "ind_id",
"reference_table": "individual",
"reference_key": "ind_id",
},
"foreign_key_to": {"column_name": "add_id", "reference_table": "address", "reference_key": "add_id"},
"label": "LIVES_IN",
"column_names_mapping": {"duration": "years"},
}
},
}
importer = CSVLocalFileSystemImporter(path=path, data_configuration=conf_with_many_to_many, memgraph=memgraph)
importer.translate(drop_database_on_start=True)


@pytest.mark.extras
@pytest.mark.arrow
Expand Down

0 comments on commit 8451528

Please sign in to comment.