-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trivial unit test for database instantiation and querying empty c…
…hunks table.
- Loading branch information
Showing
9 changed files
with
704 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: build_and_test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build_and_test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
# Need to clone everything for the git tags. | ||
fetch-depth: 0 | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
channels: conda-forge,defaults | ||
channel-priority: strict | ||
show-channel-urls: true | ||
miniforge-variant: Mambaforge | ||
use-mamba: true | ||
|
||
- name: Update pip/wheel infrastructure | ||
shell: bash -l {0} | ||
run: | | ||
mamba install -y -q pip wheel | ||
pip install uv | ||
- name: Install dependencies | ||
shell: bash -l {0} | ||
run: | | ||
uv pip install -r requirements.txt | ||
# We have two cores so we can speed up the testing with xdist | ||
- name: Install pytest packages | ||
shell: bash -l {0} | ||
run: | | ||
uv pip install \ | ||
pytest pytest-xdist pytest-cov | ||
- name: List installed packages | ||
shell: bash -l {0} | ||
run: | | ||
conda list | ||
pip list -v | ||
- name: Build and install | ||
shell: bash -l {0} | ||
run: | | ||
uv pip install -v --no-deps -e . | ||
- name: Run tests | ||
shell: bash -l {0} | ||
run: | | ||
pytest -r a -v -n 3 --cov=lsst.dax.ppdb --cov=tests --cov-report=xml --cov-report=term --cov-branch | ||
- name: Upload coverage to codecov | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
file: ./coverage.xml |
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,24 @@ | ||
# This file is part of dax_ppdb. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import pkgutil | ||
|
||
__path__ = pkgutil.extend_path(__path__, __name__) |
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,24 @@ | ||
# This file is part of dax_ppdb. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import pkgutil | ||
|
||
__path__ = pkgutil.extend_path(__path__, __name__) |
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,22 @@ | ||
# This file is part of dax_ppdb. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (http://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from ._ppdb import * |
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,65 @@ | ||
# This file is part of dax_ppdb. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (http://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from __future__ import annotations | ||
|
||
__all__ = ["PpdbTest"] | ||
|
||
import unittest | ||
from abc import ABC, abstractmethod | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from ..config import PpdbConfig | ||
from ..ppdb import Ppdb | ||
|
||
if TYPE_CHECKING: | ||
|
||
class TestCaseMixin(unittest.TestCase): | ||
"""Base class for mixin test classes that use TestCase methods.""" | ||
|
||
else: | ||
|
||
class TestCaseMixin: | ||
"""Do-nothing definition of mixin base class for regular execution.""" | ||
|
||
|
||
class PpdbTest(TestCaseMixin, ABC): | ||
"""Base class for Ppdb tests that can be specialized for concrete | ||
implementation. | ||
This can only be used as a mixin class for a unittest.TestCase and it | ||
calls various assert methods. | ||
""" | ||
|
||
@abstractmethod | ||
def make_instance(self, **kwargs: Any) -> PpdbConfig: | ||
"""Make database instance and return configuration for it.""" | ||
raise NotImplementedError() | ||
|
||
def test_empty_db(self) -> None: | ||
"""Test for instantiation a database and making queries on empty | ||
database. | ||
""" | ||
config = self.make_instance() | ||
ppdb = Ppdb.from_config(config) | ||
chunks = ppdb.get_replica_chunks() | ||
if chunks is not None: | ||
self.assertEqual(len(chunks), 0) |
Oops, something went wrong.