Skip to content

Commit

Permalink
fix bug in session commit (#26)
Browse files Browse the repository at this point in the history
session commit should occur after each job is added to avoid adding the same flowchart (identical sha256_strict) more than once
  • Loading branch information
janash authored Apr 10, 2022
1 parent 1547674 commit f37b14e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions seamm_datastore/database/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def import_datastore(session, location, as_json=True):
)
else:
session.add(job)
session.commit()
jobs.append(job)

session.commit()
Expand Down
5 changes: 5 additions & 0 deletions seamm_datastore/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@

def test_build(connection):

from seamm_datastore.database.models import Flowchart

loc = os.path.abspath(os.path.dirname(__file__))
added_jobs, added_projects = connection.import_datastore(
os.path.join(loc, "..", "data", "Projects")
)

flowcharts = Flowchart.permissions_query(permission="read").all()

assert len(added_jobs) == 2
assert len(added_projects) == 1, added_projects
assert len(flowcharts) == 1
2 changes: 1 addition & 1 deletion seamm_datastore/tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
None,
"id",
"asc",
2,
1,
1,
), # Test retrieving all flowcharts
("job", None, None, 1, None, "id", "asc", 1, 93), # Get jobs with offset
Expand Down

0 comments on commit f37b14e

Please sign in to comment.