Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/functional_test.yml
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 }}
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
2 changes: 2 additions & 0 deletions augur/application/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0611: Unused List imported from typing (unused-import) Raw Output: augur/application/config.py:5:0: W0611: Unused List imported from typing (unused-import)
import os
from augur.application.db.models import Config
from augur.application.db.util import execute_session_query, convert_type_of_value
Expand Down Expand Up @@ -546,6 +546,8 @@

def __init__(self, json_data, logger: logging.Logger):
super().__init__(logger)
if not self.writable:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since writable is hardcoded to False for JsonConfig (line 554), this condition is always true. Not wrong, but could be simplified to just always deepcopy.

Up to you though - the current form is more defensive if writable ever becomes dynamic.

Copy link
Contributor Author

@MoralCode MoralCode Jan 11, 2026

Choose a reason for hiding this comment

The 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
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ legacy_tox_ini = """
addopts = -ra -s
"""

[tool.pytest.ini_options]
addopts = "-ra -s"
testpaths = [
"tests/test_classes",
# "tests/test_routes", # runs, but needs a fixture for connecting to the web interface of Augur
# "tests/test_metrics",
# "tests/test_tasks",
# "tests/test_application",
# "tests/test_workers",
# "tests/test_workers/worker_persistence/",
# "tests/test_routes/runner.py"
]

[tool.mypy]
files = ['augur/application/db/*.py']
ignore_missing_imports = true
Expand Down
21 changes: 20 additions & 1 deletion tests/test_classes/test_config_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name) Raw Output: tests/test_classes/test_config_stores.py:17:35: W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
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

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name) Raw Output: tests/test_classes/test_config_stores.py:23:37: W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
assert JsonConfig({}, mock_logger).empty is True
assert JsonConfig({"A": {}}, mock_logger).empty is False


def test_jsonconfig_write_protection(mock_logger):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)

# 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):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)

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
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name) Raw Output: tests/test_classes/test_config_stores.py:80:49: W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
cfg = JsonConfig({"A": {"x": 1}}, mock_logger)
with pytest.raises(NotWriteableException):
getattr(cfg, callable_name)(*args, **kwargs)
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'mock_session' from outer scope (line 13) (redefined-outer-name) Raw Output: tests/test_classes/test_config_stores.py:126:45: W0621: Redefining name 'mock_session' from outer scope (line 13) (redefined-outer-name)

Check warning on line 126 in tests/test_classes/test_config_stores.py

View workflow job for this annotation

GitHub Actions / runner / pylint

[pylint] reported by reviewdog 🐶 W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name) Raw Output: tests/test_classes/test_config_stores.py:126:32: W0621: Redefining name 'mock_logger' from outer scope (line 9) (redefined-outer-name)
cfg = AugurConfig(mock_logger, mock_session)
cfg.config_sources = [JsonConfig(default_config, mock_logger)]

Expand Down
Loading