From 4e428b5afe6c4be329cc43dc0ffc1318bb43bdb9 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Tue, 5 Nov 2024 12:01:38 +0000 Subject: [PATCH 1/2] [#99] Added `tox` section to `pyproject.toml` file. --- .github/workflows/pytest.yml | 11 ------- .gitignore | 4 ++- Makefile | 9 ++---- pyproject.toml | 60 +++++++++++++++++++++++------------- requirements-dev.txt | 1 + 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index caeadf50..bb19ab00 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -13,7 +13,6 @@ jobs: name: Python ${{ matrix.python-version }} & PostgreSQL ${{ matrix.postgresql-version }} env: - # PGPASSFILE: ~/.pgpass PGPASSWORD: postgres runs-on: ubuntu-latest strategy: @@ -57,15 +56,6 @@ jobs: # When "true", encrypt connections using SSL (TLS). ssl: false - # - name: Create .pgpass file - # run: | - # echo "localhost:5432:*:postgres:postgres" > ~/.pgpass - # chmod 0600 ~/.pgpass - # echo "USER: $USER" - # echo "HOME: $HOME" - # cat ~/.pgpass - # ls -la ~ - - name: Set up TaskJuggler run: | sudo gem install taskjuggler @@ -95,7 +85,6 @@ jobs: - name: Test with pytest run: | PYTHONPATH=src python -m pytest - # --verbose -n auto -W ignore --color=yes --cov=src --cov-report html --cov-report term tests/models/test_review.py - name: Archive code coverage results uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index 37479286..df208dcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ .cache/* -.coverage +.coverage* .DS_Store .env +.mypy_cache/ .pytest_cache +.tox/ .venv/ .vscode/ *.pyc diff --git a/Makefile b/Makefile index ef5489f1..45449616 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,7 @@ install: clean: FORCE @printf "\n\033[36m--- $@: Clean ---\033[0m\n" -rm -rf .pytest_cache + -rm -f .coverage.* -rm -rf dist -rm -rf build -rm -rf docs/build @@ -49,6 +50,7 @@ clean-all: clean -rm -f setuptools-*.egg -rm -f use-distutils -rm -f .coverage* + -rm -Rf .tox -rm -Rf htmlcov -rm -rf dist -rm -Rf src/$(PACKAGE_NAME).egg-info @@ -83,16 +85,9 @@ tests: echo -e "\n\033[36m--- $@: Using python interpretter '`which python`' ---\033[0m\n"; \ PYTHONPATH=src pytest -v -n auto -W ignore --color=yes --cov=src --cov-report term --cov-fail-under 99 tests; - -# sphinx-build \ -# {tty:--color} \ -# -b html \ -# doc/sphinx/source doc/sphinx/build \ -# {posargs} .PHONY: docs docs: cd docs && $(MAKE) html - # https://www.gnu.org/software/make/manual/html_node/Force-Targets.html FORCE: diff --git a/pyproject.toml b/pyproject.toml index 00754fd3..465a6c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,26 +2,6 @@ requires = ["setuptools"] build-backend = "setuptools.build_meta" -[tool.setuptools] -include-package-data = true - -[tool.setuptools.packages.find] -where = ["src"] - -[tool.setuptools.package-data] -stalker = ["VERSION"] - -[tool.setuptools.exclude-package-data] -stalker = ["alembic", "docs", "tests"] - -[tool.setuptools.dynamic] -dependencies = { file = ["requirements.txt"] } -optional-dependencies.test = { file = ["requirements-dev.txt"] } -version = { file = ["VERSION"] } - -[tool.distutils.bdist_wheel] -universal = false - [project] authors = [ {name = "Erkan Özgür Yılmaz", email = "eoyilmaz@gmail.com"}, @@ -68,16 +48,35 @@ name = "stalker" readme = "README.rst" requires-python = ">= 3.8" - [project.urls] "Home Page" = "https://github.com/eoyilmaz/stalker" GitHub = "https://github.com/eoyilmaz/stalker" Documentation = "https://stalker.readthedocs.io" Repository = "https://github.com/eoyilmaz/stalker.git" +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +stalker = ["VERSION"] + +[tool.setuptools.exclude-package-data] +stalker = ["alembic", "docs", "tests"] + +[tool.setuptools.dynamic] +dependencies = { file = ["requirements.txt"] } +optional-dependencies.test = { file = ["requirements-dev.txt"] } +version = { file = ["VERSION"] } + +[tool.distutils.bdist_wheel] +universal = false + [tool.pytest.ini_options] pythonpath = ["."] -addopts = "-v -n auto -W ignore --color=yes --cov --cov-report html --cov-report term --cov-fail-under 99 tests" +addopts = "-n auto -W ignore --color=yes --cov --cov-report html tests" [tool.black] @@ -98,3 +97,20 @@ extend-select = ["B950"] ignore = ["D107", "E203", "E501", "E701", "SC200", "W503"] max-complexity = 12 max-line-length = 80 + +[tool.tox] +requires = ["tox>=4.23.2"] +env_list = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + +[tool.tox.env_run_base] +description = "run the tests with pytest" +package = "wheel" +wheel_build_env = ".pkg" +deps = [ + "pytest>=6", + "pytest-cov", + "pytest-xdist", +] +commands = [ + ["pytest"], +] \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 9f38ec69..eb0d678a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -19,5 +19,6 @@ pytest-xdist sphinx sphinx-autoapi # sphinx-findthedocs +tox twine wheel \ No newline at end of file From ecf96726781d59552d0c2599436c96c655759e93 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Tue, 5 Nov 2024 14:51:20 +0000 Subject: [PATCH 2/2] * [#99] Fixed an ancient huge bug in how defaults values are set in `stalker.models.studio.Studio`. * [#99] Fixed an ancient bug in `stalker.config.ConfigBase.__setitem__()` where it was setting instance attributes instead of the config values. --- src/stalker/config.py | 2 +- src/stalker/models/studio.py | 10 ++--- tests/benchmarks/task_total_logged_seonds.py | 4 +- tests/config/test_config.py | 8 ++++ tests/conftest.py | 5 +-- tests/db/test_db.py | 10 ++--- tests/mixins/test_dateRangeMixin.py | 9 ++-- tests/mixins/test_scheduleMixin.py | 43 +++++++++--------- tests/models/test_local_session.py | 2 +- tests/models/test_task.py | 47 +++++++++++++------- tests/utils.py | 2 +- 11 files changed, 85 insertions(+), 57 deletions(-) diff --git a/src/stalker/config.py b/src/stalker/config.py index 2d3769ac..4b7adf9d 100644 --- a/src/stalker/config.py +++ b/src/stalker/config.py @@ -105,7 +105,7 @@ def __setitem__(self, name, value) -> None: name (str): The name as the index. value (Any): The value to set the item to. """ - setattr(self, name, value) + self.config_values[name] = value def __delitem__(self, name: str) -> None: """Delete the item with the given name. diff --git a/src/stalker/models/studio.py b/src/stalker/models/studio.py index 1ebfc119..aa10aa51 100644 --- a/src/stalker/models/studio.py +++ b/src/stalker/models/studio.py @@ -182,7 +182,7 @@ def update_defaults(self): try: if self.daily_working_hours: - defaults.daily_working_hours = self.daily_working_hours + defaults["daily_working_hours"] = self.daily_working_hours logger.debug( "updated defaults.daily_working_hours: {}".format( defaults.daily_working_hours @@ -204,7 +204,7 @@ def update_defaults(self): ) if self.weekly_working_days: - defaults.weekly_working_days = self.weekly_working_days + defaults["weekly_working_days"] = self.weekly_working_days logger.debug( f"updated defaults.weekly_working_days: {defaults.weekly_working_days}" ) @@ -212,7 +212,7 @@ def update_defaults(self): logger.debug("can not update defaults.weekly_working_days") if self.weekly_working_hours: - defaults.weekly_working_hours = self.weekly_working_hours + defaults["weekly_working_hours"] = self.weekly_working_hours logger.debug( "updated defaults.weekly_working_hours: {}".format( defaults.weekly_working_hours @@ -222,7 +222,7 @@ def update_defaults(self): logger.debug("can not update defaults.weekly_working_hours") if self.yearly_working_days: - defaults.yearly_working_days = self.yearly_working_days + defaults["yearly_working_days"] = self.yearly_working_days logger.debug( f"updated defaults.yearly_working_days: {defaults.yearly_working_days}" ) @@ -230,7 +230,7 @@ def update_defaults(self): logger.debug("can not update defaults.yearly_working_days") if self.timing_resolution: - defaults.timing_resolution = self.timing_resolution + defaults["timing_resolution"] = self.timing_resolution logger.debug( f"updated defaults.timing_resolution: {defaults.timing_resolution}" ) diff --git a/tests/benchmarks/task_total_logged_seonds.py b/tests/benchmarks/task_total_logged_seonds.py index e6960d9f..67fa7c10 100644 --- a/tests/benchmarks/task_total_logged_seonds.py +++ b/tests/benchmarks/task_total_logged_seonds.py @@ -50,7 +50,7 @@ # regenerate the defaults # stalker.defaults = Config() stalker.defaults.config_values = stalker.defaults.default_config_values.copy() -stalker.defaults.timing_resolution = datetime.timedelta(minutes=10) +stalker.defaults["timing_resolution"] = datetime.timedelta(minutes=10) # init database stalker.db.setup.setup(config) @@ -242,7 +242,7 @@ Base.metadata.drop_all(engine, checkfirst=True) DBSession.remove() -stalker.defaults.timing_resolution = datetime.timedelta(hours=1) +stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) close_all_sessions() drop_db(**get_server_details_from_url(database_url)) diff --git a/tests/config/test_config.py b/tests/config/test_config.py index eb1bca23..e18bf5a5 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -169,6 +169,14 @@ def test_syntax_error_in_settings_file(prepare_config_file): assert str(cm.value) == error_message +def test___setattr___cannot_set_config_values_directly(prepare_config_file): + """config.Config.__setattr__() method cannot set config values directly.""" + c = config.Config() + test_value = 1 + c.daily_working_hours = test_value + assert c.config_values["daily_working_hours"] != test_value + + def test___getattr___is_working_properly(prepare_config_file): """config.Config.__getattr__() method is working properly.""" c = config.Config() diff --git a/tests/conftest.py b/tests/conftest.py index 1af37d52..616f5cd8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Configure tests.""" - import datetime import logging import os @@ -36,7 +35,7 @@ def setup_sqlite3(): # regenerate the defaults stalker.defaults.config_values = stalker.defaults.default_config_values.copy() - stalker.defaults.timing_resolution = datetime.timedelta(hours=1) + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) # Enable Debug logging log.set_level(logging.DEBUG) @@ -88,7 +87,7 @@ def setup_postgresql_db(): # regenerate the defaults stalker.defaults.config_values = stalker.defaults.default_config_values.copy() - stalker.defaults.timing_resolution = datetime.timedelta(hours=1) + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) # init database # remove anything beforehand diff --git a/tests/db/test_db.py b/tests/db/test_db.py index bbd46bb9..ffa3e699 100644 --- a/tests/db/test_db.py +++ b/tests/db/test_db.py @@ -134,9 +134,9 @@ def auto_crate_admin_on(): """Toggle auto create admin value on.""" # set default admin creation to True default_value = defaults.auto_create_admin - defaults.auto_create_admin = True + defaults["auto_create_admin"] = True yield - defaults.auto_create_admin = default_value + defaults["auto_create_admin"] = default_value @pytest.fixture(scope="function") @@ -144,9 +144,9 @@ def auto_crate_admin_off(): """Toggle auto create admin value on.""" # set default admin creation to True default_value = defaults.auto_create_admin - defaults.auto_create_admin = False + defaults["auto_create_admin"] = False yield - defaults.auto_create_admin = default_value + defaults["auto_create_admin"] = default_value def test_default_admin_creation(setup_postgresql_db, auto_crate_admin_on): @@ -191,7 +191,7 @@ def test_no_default_admin_creation(setup_postgresql_db, auto_crate_admin_off): pass # regenerate the defaults - stalker.defaults.timing_resolution = datetime.timedelta(hours=1) + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) # init the db stalker.db.setup.setup(data["config"]) diff --git a/tests/mixins/test_dateRangeMixin.py b/tests/mixins/test_dateRangeMixin.py index 59230144..28c24a1d 100644 --- a/tests/mixins/test_dateRangeMixin.py +++ b/tests/mixins/test_dateRangeMixin.py @@ -41,6 +41,7 @@ def date_range_mixin_tester(): """ # create mock objects stalker.defaults.config_values = stalker.defaults.default_config_values.copy() + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) data = dict() data["start"] = datetime.datetime(2013, 3, 22, 15, 15, tzinfo=pytz.utc) data["end"] = data["start"] + datetime.timedelta(days=20) @@ -54,7 +55,9 @@ def date_range_mixin_tester(): "duration": data["duration"], } data["test_foo_obj"] = DateRangeMixFooMixedInClass(**data["kwargs"]) - return data + yield data + stalker.defaults.config_values = stalker.defaults.default_config_values.copy() + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) @pytest.mark.parametrize("test_value", [1, 1.2, "str", ["a", "date"]]) @@ -181,7 +184,7 @@ def test_duration_argument_is_not_an_instance_of_date_if_end_argument_is_missing ): """defaults.timing_resolution is used if the duration arg is not a datetime and if end arg is also missing.""" data = date_range_mixin_tester - defaults.timing_resolution = datetime.timedelta(hours=1) + defaults["timing_resolution"] = datetime.timedelta(hours=1) # some wrong values for the duration data["kwargs"].pop("end") data["kwargs"]["duration"] = test_value @@ -425,7 +428,7 @@ def test_start_end_and_duration_values_are_rounded_to_the_default_timing_resolut data["kwargs"]["end"] = datetime.datetime( 2013, 3, 24, 16, 46, 32, 102, tzinfo=pytz.utc ) - defaults.timing_resolution = datetime.timedelta(minutes=5) + defaults["timing_resolution"] = datetime.timedelta(minutes=5) new_foo_obj = DateRangeMixFooMixedInClass(**data["kwargs"]) # check the start diff --git a/tests/mixins/test_scheduleMixin.py b/tests/mixins/test_scheduleMixin.py index de9f9730..426af4ce 100644 --- a/tests/mixins/test_scheduleMixin.py +++ b/tests/mixins/test_scheduleMixin.py @@ -28,10 +28,11 @@ def __init__(self, **kwargs): def setup_schedule_mixin_tests(): """Set up the tests for the ScheduleMixin. - Returns: + Yields: dict: Test data. """ stalker.defaults.config_values = stalker.defaults.default_config_values.copy() + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) data = dict() data["kwargs"] = { "name": "Test Object", @@ -41,7 +42,9 @@ def setup_schedule_mixin_tests(): "schedule_constraint": 0, } data["test_obj"] = MixedInClass(**data["kwargs"]) - return data + yield data + stalker.defaults.config_values = stalker.defaults.default_config_values.copy() + stalker.defaults["timing_resolution"] = datetime.timedelta(hours=1) def test_schedule_model_attribute_is_effort_by_default(setup_schedule_mixin_tests): @@ -243,7 +246,7 @@ def test_schedule_timing_argument_skipped(setup_schedule_mixin_tests): def test_schedule_timing_argument_is_none(setup_schedule_mixin_tests): """schedule_timing==Config.timing_resolution.seconds/60 if the schedule_timing arg is None.""" data = setup_schedule_mixin_tests - defaults.timing_resolution = datetime.timedelta(hours=1) + defaults["timing_resolution"] = datetime.timedelta(hours=1) data["kwargs"]["schedule_timing"] = None new_task = MixedInClass(**data["kwargs"]) assert new_task.schedule_timing == defaults.timing_resolution.seconds / 60.0 @@ -252,7 +255,7 @@ def test_schedule_timing_argument_is_none(setup_schedule_mixin_tests): def test_schedule_timing_attribute_is_set_to_none(setup_schedule_mixin_tests): """schedule_timing==Config.timing_resolution.seconds/60 if it is set to None.""" data = setup_schedule_mixin_tests - defaults.timing_resolution = datetime.timedelta(hours=1) + defaults["timing_resolution"] = datetime.timedelta(hours=1) data["test_obj"].schedule_timing = None assert data["test_obj"].schedule_timing == defaults.timing_resolution.seconds / 60.0 @@ -420,10 +423,10 @@ def test_least_meaningful_time_unit_is_working_properly( """least_meaningful_time_unit is working properly.""" data = setup_schedule_mixin_tests - defaults.daily_working_hours = 9 - defaults.weekly_working_days = 5 - defaults.weekly_working_hours = 45 - defaults.yearly_working_days = 52.1428 * 5 + defaults["daily_working_hours"] = 9 + defaults["weekly_working_days"] = 5 + defaults["weekly_working_hours"] = 45 + defaults["yearly_working_days"] = 52.1428 * 5 assert expected_result == data["test_obj"].least_meaningful_time_unit(*input_value) @@ -464,10 +467,10 @@ def test_to_seconds_is_working_properly( """to_seconds method is working properly.""" data = setup_schedule_mixin_tests - defaults.daily_working_hours = 9 - defaults.weekly_working_days = 5 - defaults.weekly_working_hours = 45 - defaults.yearly_working_days = 52.1428 * 5 + defaults["daily_working_hours"] = 9 + defaults["weekly_working_days"] = 5 + defaults["weekly_working_hours"] = 45 + defaults["yearly_working_days"] = 52.1428 * 5 data["test_obj"].schedule_model = schedule_model data["test_obj"].schedule_timing = schedule_timing @@ -520,10 +523,10 @@ def test_to_unit_is_working_properly( """to_unit method is working properly.""" data = setup_schedule_mixin_tests - defaults.daily_working_hours = 9 - defaults.weekly_working_days = 5 - defaults.weekly_working_hours = 45 - defaults.yearly_working_days = 52.1428 * 5 + defaults["daily_working_hours"] = 9 + defaults["weekly_working_days"] = 5 + defaults["weekly_working_hours"] = 45 + defaults["yearly_working_days"] = 52.1428 * 5 assert schedule_timing == data["test_obj"].to_unit( seconds, schedule_unit, schedule_model @@ -566,10 +569,10 @@ def test_schedule_seconds_is_working_properly( """schedule_seconds property is working properly.""" data = setup_schedule_mixin_tests - defaults.daily_working_hours = 9 - defaults.weekly_working_days = 5 - defaults.weekly_working_hours = 45 - defaults.yearly_working_days = 52.1428 * 5 + defaults["daily_working_hours"] = 9 + defaults["weekly_working_days"] = 5 + defaults["weekly_working_hours"] = 45 + defaults["yearly_working_days"] = 52.1428 * 5 data["test_obj"].schedule_model = schedule_model data["test_obj"].schedule_timing = schedule_timing diff --git a/tests/models/test_local_session.py b/tests/models/test_local_session.py index 5288a055..8650b424 100644 --- a/tests/models/test_local_session.py +++ b/tests/models/test_local_session.py @@ -18,7 +18,7 @@ @pytest.fixture(scope="function") def setup_local_session_tester(): """Set up the LocalSession related tests.""" - defaults.local_storage_path = tempfile.mktemp() + defaults["local_storage_path"] = tempfile.mktemp() yield shutil.rmtree(defaults.local_storage_path, True) diff --git a/tests/models/test_task.py b/tests/models/test_task.py index a54e2d19..6f6650c2 100644 --- a/tests/models/test_task.py +++ b/tests/models/test_task.py @@ -28,7 +28,6 @@ TimeLog, Type, User, - db, defaults, ) from stalker.db.session import DBSession @@ -41,7 +40,11 @@ def setup_task_tests(): """tests that doesn't require a database.""" data = dict() - stalker.defaults.config_values = stalker.defaults.default_config_values.copy() + defaults.config_values = defaults.default_config_values.copy() + defaults["timing_resolution"] = datetime.timedelta(hours=1) + assert defaults.daily_working_hours == 9 + assert defaults.weekly_working_days == 5 + assert defaults.yearly_working_days == 261 data["status_wfd"] = Status(name="Waiting For Dependency", code="WFD") data["status_rts"] = Status(name="Ready To Start", code="RTS") @@ -165,7 +168,9 @@ def setup_task_tests(): "status": 0, "status_list": data["task_status_list"], } - return data + yield data + defaults.config_values = copy.deepcopy(defaults.default_config_values) + defaults["timing_resolution"] = datetime.timedelta(hours=1) def test___auto_name__class_attribute_is_set_to_false(): @@ -1231,9 +1236,9 @@ def test_schedule_seconds_is_working_properly_for_an_effort_based_task_no_studio "schedule_timing, schedule_unit, schedule_seconds", [ [10, "h", 10 * 3600], - [23, "d", 23 * 9 * 3600], - [2, "w", 2 * 45 * 3600], - [2.5, "m", 2.5 * 4 * 45 * 3600], + [23, "d", 23 * 8 * 3600], + [2, "w", 2 * 40 * 3600], + [2.5, "m", 2.5 * 4 * 40 * 3600], # [ # 3.1, # "y", @@ -1248,8 +1253,12 @@ def test_schedule_seconds_is_working_properly_for_an_effort_based_task_with_stud data = setup_task_tests kwargs = copy.copy(data["kwargs"]) # no studio, using defaults - defaults.timing_resolution = datetime.timedelta(hours=1) - studio = Studio(name="Test Studio", timing_resolution=datetime.timedelta(hours=1)) + defaults["timing_resolution"] = datetime.timedelta(hours=1) + _ = Studio( + name="Test Studio", + daily_working_hours=8, + timing_resolution=datetime.timedelta(hours=1) + ) kwargs["schedule_model"] = "effort" kwargs["schedule_timing"] = schedule_timing kwargs["schedule_unit"] = schedule_unit @@ -1259,6 +1268,9 @@ def test_schedule_seconds_is_working_properly_for_an_effort_based_task_with_stud def test_schedule_seconds_is_working_properly_for_a_container_task(setup_task_tests): """schedule_seconds attr is working properly for a container task.""" + assert defaults.daily_working_hours == 9 + assert defaults.weekly_working_days == 5 + assert defaults.yearly_working_days == 261 data = setup_task_tests # no studio, using defaults kwargs = copy.copy(data["kwargs"]) @@ -1326,6 +1338,9 @@ def test_schedule_seconds_is_working_okay_for_a_container_task_if_the_child_is_u setup_task_tests, ): """schedule_seconds attr is working properly for a container task.""" + assert defaults.daily_working_hours == 9 + assert defaults.weekly_working_days == 5 + assert defaults.yearly_working_days == 261 data = setup_task_tests kwargs = copy.copy(data["kwargs"]) # no studio, using defaults @@ -1410,8 +1425,8 @@ def test_schedule_seconds_is_working_okay_for_a_task_if_the_child_is_updated_dee """schedule_seconds attr is working properly for a container task.""" data = setup_task_tests kwargs = copy.copy(data["kwargs"]) - defaults.timing_resolution = datetime.timedelta(hours=1) - defaults.daily_working_hours = 9 + defaults["timing_resolution"] = datetime.timedelta(hours=1) + defaults["daily_working_hours"] = 9 # no studio, using defaults parent_task1 = Task(**kwargs) assert parent_task1.schedule_seconds == 9 * 3600 @@ -4644,8 +4659,8 @@ def test_percent_complete_attr_is_working_properly_for_a_container_task( td = datetime.timedelta now = dt.now(pytz.utc) - defaults.timing_resolution = td(hours=1) - defaults.daily_working_hours = 9 + defaults["timing_resolution"] = td(hours=1) + defaults["daily_working_hours"] = 9 parent_task = Task(**kwargs) @@ -4690,8 +4705,8 @@ def test_percent_complete_attr_working_okay_for_a_task_w_effort_and_duration_chi dt = datetime.datetime td = datetime.timedelta - defaults.timing_resolution = td(hours=1) - defaults.daily_working_hours = 9 + defaults["timing_resolution"] = td(hours=1) + defaults["daily_working_hours"] = 9 now = DateRangeMixin.round_time(dt.now(pytz.utc)) @@ -4761,8 +4776,8 @@ def test_percent_complete_attr_is_okay_for_a_task_with_effort_and_length_based_c dt = datetime.datetime td = datetime.timedelta - defaults.timing_resolution = td(hours=1) - defaults.daily_working_hours = 9 + defaults["timing_resolution"] = td(hours=1) + defaults["daily_working_hours"] = 9 now = DateRangeMixin.round_time(dt.now(pytz.utc)) diff --git a/tests/utils.py b/tests/utils.py index 5f4542aa..f8e192dd 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -261,7 +261,7 @@ def tear_down_db(data): except OperationalError: pass finally: - defaults.timing_resolution = datetime.timedelta(hours=1) + defaults["timing_resolution"] = datetime.timedelta(hours=1) def get_admin_user():