-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use pytest: unittest -> pytest translation * use pytest: CI update & dependencies, including coverage * pytest in dev dependencies * empty tests/__init__.py * Update .github/workflows/ci.yml
- Loading branch information
Showing
7 changed files
with
269 additions
and
279 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 |
---|---|---|
@@ -1,32 +1,37 @@ | ||
name: ci | ||
|
||
on: [push, pull_request] | ||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
python-version: [ "3.9", "3.10", "3.11", "3.12" ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Install python dependencies | ||
run: | | ||
poetry env use ${{ matrix.python-version }} | ||
poetry install --with dev | ||
- name: Install python dependencies | ||
run: | | ||
poetry env use ${{ matrix.python-version }} | ||
poetry install --with dev | ||
- name: Run unit tests | ||
run: | | ||
poetry run python -m unittest -v tests | ||
- name: Run unit tests | ||
run: | | ||
poetry run pytest --cov=abcd --cov-report xml --cov-report term:skip-covered | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4.4.1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
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 |
---|---|---|
@@ -1,9 +0,0 @@ | ||
import unittest | ||
from tests.parsers import ParsingQueries, ParsingExtras | ||
from tests.database import Mongo | ||
|
||
import logging | ||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.INFO) | ||
unittest.main(verbosity=1, exit=False) | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import pytest | ||
import mongomock | ||
|
||
from abcd import ABCD | ||
|
||
from io import StringIO | ||
from ase.io import read | ||
|
||
|
||
@pytest.fixture | ||
@mongomock.patch(servers=(('localhost', 27017),)) | ||
def abcd_mongodb(): | ||
url = 'mongodb://localhost' | ||
abcd = ABCD.from_url(url) | ||
abcd.print_info() | ||
|
||
return abcd | ||
|
||
|
||
def test_thing(abcd_mongodb): | ||
print(abcd_mongodb.info()) | ||
|
||
|
||
def test_push(abcd_mongodb): | ||
xyz = StringIO("""2 | ||
Properties=species:S:1:pos:R:3 s="sadf" _vtk_test="t e s t _ s t r" pbc="F F F" | ||
Si 0.00000000 0.00000000 0.00000000 | ||
Si 0.00000000 0.00000000 0.00000000 | ||
""") | ||
|
||
atoms = read(xyz, format='extxyz') | ||
atoms.set_cell([1, 1, 1]) | ||
|
||
abcd_mongodb.destroy() | ||
abcd_mongodb.push(atoms) | ||
new = list(abcd_mongodb.get_atoms())[0] | ||
|
||
assert atoms == new |
Oops, something went wrong.