-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat/testing: add tests to ensure that code works as intended #27
Conversation
Switch the Test OS as the one we use for the Docker is also arch, so this should increase compatibility of the code with the test. (Very unlikely that there would have been any problems on Ubuntu, but worth fixing up).
This reverts accidental commit 9f1eb55.
Looks good so far! In the future I will try to make this run on archlinux, like the docker so we have maximum compatibility between the docker and the testing environment. |
thanks @tiaguinho-code ! |
is there a reason for reverting the changes, did it not pass the tests ? |
If I see correctly I reverted my own accidental push, where I tried to configure the testing os. If I reverted any of your commits that must have been a mistake. |
No I meant your commit, but no worries! You can perhaps check if something you want to push passes |
Yeah, will do. I reverted my commit because I was just messing around a bit and the test got stuck, so I guess I must have broken it lol |
Looks great to me! Thank you @mlederbauer for implementing the tests and pipeline! I approved the changes and imo we can already merge it if thats alright with you @tiaguinho-code since we have working tests and the switch to arch is not urgent rn |
thx guys! @tiaguinho-code @kbiniek |
TLDR: What does this mean for developing this code? Nothing really, you get a checkmark that tells you whether the tests "passed" or not. This so-called unit testing is standard practice to check whether the code works as intended, and is not broken at any stage of coding. When adding a new feature, it would be good to add tests in the directory
tests/
- but it shouldn't be a priority right now. Mainly, I've been experimenting with github workflows and this is a first attempt :)This pull request introduces several changes aimed at improving the quality and reliability of the NMRcraft codebase. Specifically, it adds a suite of unit tests and a continuous integration (CI) workflow that runs these tests automatically whenever code is pushed to the main branch or a pull request is opened against it.
Unit Tests
The new unit tests are located in the tests/ directory. These tests cover the load_model function in nmrcraft/models/models.py, ensuring that it correctly loads the supported models and raises an error when an unsupported model or keyword argument is provided.
Here's an example of one of the new tests:
This test asserts that a ValueError is raised when we try to load a model named "unsupported_model", which is not supported by the load_model function.
Continuous Integration Workflow
Continuous Integration Workflow
The new CI workflow is defined in .github/workflows/tests.yml. This workflow runs on Ubuntu and performs the following steps:
Here's an excerpt from the workflow file:
With these changes, we can ensure that all tests pass before any code is merged into the main branch, helping to prevent bugs and regressions.
Please review these changes and let me know if you have any questions or feedback.