Skip to content

Commit

Permalink
made tests use keyword arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Exu-112 committed Jul 8, 2024
1 parent 8758e3e commit f16aeaa
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions tests/test_astrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,20 @@ def test_ingest_parallaxes(temp_db, t_plx):

def test_parallax_exceptions(temp_db):
with pytest.raises(AstroDBError) as error_message:
ingest_parallax(temp_db, "bad source", 1, 0, "Ref 1")
ingest_parallax(
temp_db, source="bad source", parallax=1, plx_error=0, reference="Ref 1"
)
assert "does not exist in Sources table" in str(error_message.value)

flags = ingest_parallax(temp_db, "bad source", 1, 0, "Ref 1", "comment", False)
flags = ingest_parallax(
temp_db,
source="bad source",
parallax=1,
plx_error=0,
reference="Ref 1",
comment="comment",
raise_error=False,
)
assert flags == {
"added": False,
"content": {
Expand All @@ -118,11 +128,20 @@ def test_parallax_exceptions(temp_db):
}

with pytest.raises(AstroDBError) as error_message:
ingest_parallax(temp_db, "Fake 1", 1, 0, "bad ref")
ingest_parallax(
temp_db, source="Fake 1", parallax=1, plx_error=0, reference="bad ref"
)
assert "does not exist in Publications table" in str(error_message.value)

flags = ingest_parallax(temp_db, "Fake 1", 1, 0, "bad ref", "comment", False)
print(flags)
flags = ingest_parallax(
temp_db,
source="Fake 1",
parallax=1,
plx_error=0,
reference="bad ref",
comment="comment",
raise_error=False,
)
assert flags == {
"added": False,
"content": {
Expand All @@ -136,15 +155,26 @@ def test_parallax_exceptions(temp_db):
"message": "Reference 'bad ref' does not exist in Publications table. ",
}

ingest_parallax(temp_db, "Fake 2", 1, 1, "Ref 2")
ingest_parallax(
temp_db, source="Fake 2", parallax=1, plx_error=1, reference="Ref 2"
)
with pytest.raises(AstroDBError) as error_message:
ingest_parallax(temp_db, "Fake 2", 1, 1, "Ref 2")
ingest_parallax(
temp_db, source="Fake 2", parallax=1, plx_error=1, reference="Ref 2"
)
assert "Duplicate measurement exists with same reference" in str(
error_message.value
)

flags = ingest_parallax(temp_db, "Fake 2", 1, 1, "Ref 2", "comment", False)
print(flags)
flags = ingest_parallax(
temp_db,
source="Fake 2",
parallax=1,
plx_error=1,
reference="Ref 2",
comment="comment",
raise_error=False,
)
assert flags == {
"added": False,
"content": {},
Expand Down

0 comments on commit f16aeaa

Please sign in to comment.