-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from alephdata/feature/write-object-deprecated
Use write_entity instead of deprecated write_object
- Loading branch information
Showing
7 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{"id":"637427924ad445058bd0f19d67add26a.b97aa090345d3f0725a2135954cba8d51a912e54","mutable":true,"role_id":4,"created_at":null,"updated_at":"2024-03-18T18:34:44.510358","origin":"model","schema":"Person","properties":{"name":["Carlos Danger"],"nationality":["us"]}} | ||
{"id":"98c8d8d56eb241ccb0996a9e6f69007a.80b47167fc0bb2551b90583596a23a54d75608be","mutable":true,"role_id":4,"created_at":null,"updated_at":"2024-03-18T18:34:44.574715","origin":"model","schema":"LegalEntity","properties":{"name":["Carlos Danger"],"country":["gb"]}} | ||
{"id":"caa695fa11c44488b064aa22971fccdc.4a41a3439e6d2ab55fba7f7fec1d8be53de21fa2","mutable":true,"role_id":null,"created_at":"2024-03-18T18:34:43.110728","updated_at":"2024-03-18T18:34:43.109976","origin":"model","schema":"Note","properties":{"entity":["fbc529fbcee44a588438cdb2f3ff9b3f.e4fae2145ec67c7ed22a2ab38932e7c004ed29f7"],"description":["note"]}} | ||
{"id":"d8fa04818236482693955c2d74acb7e8.68311e6a7c472bd286c01bf578d3dfd04e8458bd","mutable":true,"role_id":4,"created_at":null,"updated_at":"2024-03-18T18:34:44.631827","origin":"model","schema":"Person","properties":{"name":["Pure Risk"],"nationality":["us"]}} | ||
{"id":"fbc529fbcee44a588438cdb2f3ff9b3f.e4fae2145ec67c7ed22a2ab38932e7c004ed29f7","mutable":true,"role_id":null,"created_at":"2024-03-18T18:34:43.110727","updated_at":"2024-03-18T18:34:43.109784","origin":"model","schema":"Company","properties":{"name":["KwaZulu"],"alias":["kwazulu"]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pathlib import Path | ||
import tempfile | ||
|
||
from ftmstore import init | ||
from ftmstore.utils import write_stream, iterate_stream | ||
|
||
|
||
def test_input_output(): | ||
uri = "sqlite://" | ||
dataset = init("IO-TEST", database_uri=uri) | ||
assert dataset.name == "IO-TEST" | ||
assert len(dataset.store) == 0 | ||
|
||
input_file = Path("./tests/fixtures/entities") | ||
|
||
with open(input_file, "r") as f: | ||
data = f.readlines() | ||
|
||
number_of_entities = len(data) | ||
|
||
# test writing FTM entities to FTM Store | ||
write_stream(dataset, open(input_file, "r")) | ||
assert len(dataset) == number_of_entities | ||
|
||
# test reading FTM entities from FTM Store | ||
output_file = Path("./tests/fixtures/temp_output") | ||
|
||
fh = open(output_file, "w+b") | ||
iterate_stream(dataset, fh) | ||
fh.close() | ||
|
||
with open(output_file, "r") as f: | ||
assert len(f.readlines()) == number_of_entities | ||
|
||
output_file.unlink() | ||
|
||
dataset.drop() | ||
dataset.store.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters