Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test number of total sources and split up by publication. #73

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from astrodbkit2.astrodb import or_
import numpy as np


###### now, we test database functionality, self-consistency, etc. #####

def test_setup_db(db):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In SIMPLE, I use a conftest.py to do these type of things.

# Some setup tasks to ensure some data exists in the database first
ref_data = [
Expand Down
27 changes: 27 additions & 0 deletions tests/test_sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
This module tests the Sources table, mainly to ensure that we have as many sources as we expect.

This forces us to update tests on ingest!
"""

from sqlalchemy import and_, or_
import pytest
from astropy.io.votable.ucd import check_ucd, parse_ucd, UCDWords
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these imports are used




@pytest.mark.parametrize(
"reference, value",
[
("Perlmutter99", 1),
("Rubin80", 2),
],
)
def test_sources_reference(db, reference, value):
sources = db.query(db.Sources).filter(
or_(
db.Sources.c.reference == reference,

)
).astropy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to use .count() or similar instead of getting a table output

assert len(sources) == value, f"found {len(sources)} sources for {reference}"
Loading