-
Notifications
You must be signed in to change notification settings - Fork 995
add CI job for running the unit tests #3513
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
Changes from all commits
64ad1a5
b5920e1
0fb462a
43aaf92
d0da031
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: "Functional tests" | ||
| # Runs automated test suites that ensure functionality is preserved. Any failures should prevent code from shipping. | ||
| on: | ||
| pull_request: | ||
| branches: [main, release] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: test with ${{ matrix.env }} on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
MoralCode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| timeout-minutes: 15 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| env: ["3.10", "3.11"] #, "3.12", "3.13", "3.14" | ||
| os: [ubuntu-latest, macos-latest] | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| enable-cache: true | ||
|
|
||
| - name: Run Tests | ||
| run: | | ||
| uv run --python ${{ matrix.env }} pytest \ | ||
| tests/test_classes \ | ||
| --color=yes | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| from sqlalchemy import and_, update | ||
| import json | ||
| import copy | ||
| from typing import List, Any, Optional | ||
|
Check warning on line 5 in augur/application/config.py
|
||
| import os | ||
| from augur.application.db.models import Config | ||
| from augur.application.db.util import execute_session_query, convert_type_of_value | ||
|
|
@@ -546,6 +546,8 @@ | |
|
|
||
| def __init__(self, json_data, logger: logging.Logger): | ||
| super().__init__(logger) | ||
| if not self.writable: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Up to you though - the current form is more defensive if writable ever becomes dynamic.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah i think im anticipating the possibility of something writable since I really want to move away from having config in a database in the long term. I just think we maybe need a better backend for it (maybe a config oriented version of keyman?) that isnt just an in-memory dict (too volatile) or file on disk (no way to deal with conflicts between what the user wants and what augur is trying to set) |
||
| json_data = copy.deepcopy(json_data) | ||
| self.json_data = json_data | ||
|
|
||
| @property | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,23 +14,42 @@ | |
| return Mock() | ||
|
|
||
|
|
||
| def test_jsonconfig_readonly_flags(mock_logger): | ||
|
Check warning on line 17 in tests/test_classes/test_config_stores.py
|
||
| cfg = JsonConfig({"A": {"x": 1}}, mock_logger) | ||
| assert cfg.writable is False | ||
| assert cfg.empty is False | ||
|
|
||
|
|
||
| def test_jsonconfig_empty_true_false(mock_logger): | ||
|
Check warning on line 23 in tests/test_classes/test_config_stores.py
|
||
| assert JsonConfig({}, mock_logger).empty is True | ||
| assert JsonConfig({"A": {}}, mock_logger).empty is False | ||
|
|
||
|
|
||
| def test_jsonconfig_write_protection(mock_logger): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
| # JsonConfig should be not writeable by default, so we should be unable to change | ||
| # its values, even by abusing references | ||
|
|
||
| data = {"Alpha": {"a": 1, "b": "str"}, "Beta": {}} | ||
| cfg = JsonConfig(data, mock_logger) | ||
|
|
||
| # mutation via input | ||
| data["Alpha"]["a"] = 2 | ||
|
|
||
| config_test = cfg.retrieve_dict() | ||
| assert config_test != data # the data in the config should not change | ||
|
|
||
| # mutation via output | ||
| config_test["Alpha"]["a"] = 3 | ||
|
|
||
| config_test = cfg.retrieve_dict() | ||
| assert config_test != data # the data in the config should not change | ||
|
|
||
| def test_jsonconfig_retrieve_has_get(mock_logger): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
| data = {"Alpha": {"a": 1, "b": "str"}, "Beta": {}} | ||
| cfg = JsonConfig(data, mock_logger) | ||
|
|
||
| # retrieve full dict | ||
| assert cfg.retrieve_dict() is data | ||
| assert cfg.retrieve_dict() == data | ||
|
|
||
| # has/get section | ||
| assert cfg.has_section("Alpha") is True | ||
|
|
@@ -58,7 +77,7 @@ | |
| ("add_value", ("X", "y", 2), {"ignore_existing": False}), | ||
| ], | ||
| ) | ||
| def test_jsonconfig_mutations_raise_not_writable(mock_logger, callable_name, args, kwargs): | ||
|
Check warning on line 80 in tests/test_classes/test_config_stores.py
|
||
| cfg = JsonConfig({"A": {"x": 1}}, mock_logger) | ||
| with pytest.raises(NotWriteableException): | ||
| getattr(cfg, callable_name)(*args, **kwargs) | ||
|
|
@@ -104,7 +123,7 @@ | |
|
|
||
|
|
||
|
|
||
| def test_fetching_real_defaults(mock_logger, mock_session): | ||
|
Check warning on line 126 in tests/test_classes/test_config_stores.py
|
||
| cfg = AugurConfig(mock_logger, mock_session) | ||
| cfg.config_sources = [JsonConfig(default_config, mock_logger)] | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.