Skip to content

Commit

Permalink
Merge pull request #50 from mfschubert/master
Browse files Browse the repository at this point in the history
Add comments to test/ci files
  • Loading branch information
polyanskiy authored Dec 3, 2024
2 parents a29a08d + bf34807 commit c71ee98
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This `dependabot.yml` file handles automatic security/version updates. In this repo,
# it may e.g. update the version of the checkout action used in the `test.yml` action.
# See https://github.com/dependabot/dependabot-core for additional info.

version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # Location of package manifests
schedule:
interval: "daily"

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# This `test.yml` file defines a GitHub action that will run for all pull requests,
# and for all pushes to main. It installs the python test libraries `parameterized`
# and `pytest`, and then runs the `pytest` command. This automatically detects
# `test_*.py` files and executes tests therein.

name: CI

on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 13 * * 1" # Every Monday at 9AM EST
- master
# schedule:
# - cron: "0 13 * * 1" # Every Monday at 9AM EST

jobs:
test-parsing:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk

# =========================
# Pytest files
# =========================

tests/__pycache__
1 change: 1 addition & 0 deletions database/data-nk/main/ZnGeP2/Boyd-20-o.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# refractiveindex.info database is in the public domain
# copyright and related rights waived via CC0 1.0

REFERENCES: |
1) G. D. Boyd, E. Buehler, F. G Storz.
Linear and nonlinear optical properties of ZnGeP<sub>2</sub> and CdSe.
<a href="https://doi.org/10.1063/1.1653673"><i>Appl. Phys. Lett.</i>, <b>18</b>, 301-304 (1971)</a><br>
Expand Down
19 changes: 18 additions & 1 deletion tests/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
"""Tests that all files can be parsed."""
"""Tests that all files can be parsed.
This test can be run by the command
pytest tests/test_parse.py
or simply `pytest` from the repo directory. (The latter will automatically discover
all test files.) This test recursively discovers all `.yml` files in the `database`
directory and then loads them with the python `yaml` package.
A test is generated individually for each `.yml` file, with the test name derived from
the `.yml` file path. For example, the test for file `database/data/nk/main/KBr/Li.yml`
will be `test_can_parase_database_data_nk_main_KBr_Li_yml`.
"""

import pathlib
import unittest
import yaml
from parameterized import parameterized

# Discover the paths for all `.yml` files.
DATABASE_PATH = pathlib.Path(__file__).resolve().parent.parent / "database"
PATHS = list(DATABASE_PATH.rglob("*.yml"))


def custom_name_func(testcase_func, param_num, param):
# Generate the custom test name from the test arguments.
del param_num
path = str(param.args[0])
assert "/database/" in path
path = path[path.index("/database/") :]
return f"{testcase_func.__name__}{parameterized.to_safe_name(path)}"


Expand Down

0 comments on commit c71ee98

Please sign in to comment.