diff --git a/.github/workflows/CDA-testing.yml b/.github/workflows/CDA-testing.yml index 897b772b..62102783 100644 --- a/.github/workflows/CDA-testing.yml +++ b/.github/workflows/CDA-testing.yml @@ -60,7 +60,7 @@ jobs: # Use actions-poetry to handle installation - name: Install Poetry and Dependencies - uses: abatilo/actions-poetry@v4 + uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 # Set Poetry to use an in-project virtual environment - name: Configure Poetry for in-project venv @@ -85,7 +85,7 @@ jobs: run: poetry run pytest tests/cda/ --doctest-modules --cov --cov-report=xml:out/coverage.xml - name: Generate Coverage Report - uses: irongut/CodeCoverageSummary@v1.3.0 + uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 with: filename: out/coverage.xml format: markdown @@ -93,7 +93,7 @@ jobs: badge: true - name: Generate Job Summary - uses: x-color/github-actions-job-summary@v0.1.1 + uses: x-color/github-actions-job-summary@91bbfe6fb3ba53c9d0304991601cf2508e8098a2 # v0.1.1 with: file: ./code-coverage-results.md vars: |- diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index 1ff93b44..4cf695fa 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -22,8 +22,8 @@ jobs: # below simply check the source code and fail if they find any files that need to be # formatted. The code is not automatically reformatted like it is when running the # pre-commit hooks. - - uses: psf/black@stable + - uses: psf/black@87928e6d6761a4a6d22250e1fee5601b3998086e # stable with: # Specify the desired Black version version: "24.10.0" - - uses: isort/isort-action@v1 + - uses: isort/isort-action@24d8a7a51d33ca7f36c3f23598dafa33f7071326 # v1 diff --git a/.github/workflows/pypi-deploy.yml b/.github/workflows/pypi-deploy.yml index 7539afea..e4c94fe5 100644 --- a/.github/workflows/pypi-deploy.yml +++ b/.github/workflows/pypi-deploy.yml @@ -49,7 +49,7 @@ jobs: with: python-version: '3.x' - name: Install Poetry - uses: abatilo/actions-poetry@v4 + uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 - name: Install Dependencies env: POETRY_INSTALLER_ONLY_BINARY: ':all:' @@ -91,7 +91,7 @@ jobs: name: package-dist path: dist/ - name: Publish Distribution To PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 - name: Sign Distribution uses: sigstore/gh-action-sigstore-python@790bc6befb9d733738f18d8f895854b453640ec9 # v3.5.0 with: diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a1bc7e97..0c007938 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -33,7 +33,7 @@ jobs: # Unlike the code-check workflow, this job requires the dev dependencies to be # installed to make sure we have the necessary, tools, stub files, etc. - name: Install Poetry - uses: abatilo/actions-poetry@v4 + uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 - name: Cache Virtual Environment uses: actions/cache@v6 @@ -57,7 +57,7 @@ jobs: run: poetry run mypy --strict cwms/ - name: Generate Coverage Report - uses: irongut/CodeCoverageSummary@v1.3.0 + uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 with: filename: out/coverage.xml format: markdown @@ -65,7 +65,7 @@ jobs: badge: true - name: Generate Job Summary - uses: x-color/github-actions-job-summary@v0.1.1 + uses: x-color/github-actions-job-summary@91bbfe6fb3ba53c9d0304991601cf2508e8098a2 # v0.1.1 with: file: ./code-coverage-results.md vars: |- diff --git a/compose_files/sql/users.sql b/compose_files/sql/users.sql index f9368274..77732261 100644 --- a/compose_files/sql/users.sql +++ b/compose_files/sql/users.sql @@ -4,14 +4,16 @@ declare type office_list_t is table of varchar2(16); procedure add_full_admin(p_user varchar2, p_offices office_list_t) is + i pls_integer := p_offices.first; begin - for i in 1 .. p_offices.count loop + while i is not null loop cwms_sec.add_cwms_user(p_user, NULL, p_offices(i)); cwms_sec.add_user_to_group(p_user, 'All Users', p_offices(i)); cwms_sec.add_user_to_group(p_user, 'CWMS Users', p_offices(i)); cwms_sec.add_user_to_group(p_user, 'TS ID Creator', p_offices(i)); cwms_sec.add_user_to_group(p_user, 'CWMS User Admins', p_offices(i)); cwms_sec.add_user_to_group(p_user, 'CWMS PD Users', p_offices(i)); + i := p_offices.next(i); end loop; end; begin diff --git a/tests/cda/levels/location_levels_cda_test.py b/tests/cda/levels/location_levels_cda_test.py index 6ebacc7a..19dd5d91 100644 --- a/tests/cda/levels/location_levels_cda_test.py +++ b/tests/cda/levels/location_levels_cda_test.py @@ -12,6 +12,7 @@ import cwms.levels.location_levels as location_levels import cwms.locations.physical_locations as locations +from cwms.api import ApiError # Load test location level from tests/cda/resources/location_level.json LEVEL_RESOURCE_PATH = Path(__file__).parent.parent / "resources" / "location_level.json" @@ -111,12 +112,19 @@ def test_delete_loc_level(): data["level-date"] = temp_effective_date.isoformat() data["constant-value"] = 300 location_levels.store_location_level(data) + created = location_levels.get_location_level( + level_id=TEST_LEVEL_ID, + office_id=TEST_OFFICE, + effective_date=temp_effective_date, + unit=TEST_UNIT, + ) + assert pd.to_datetime(created.json["level-date"]) == temp_effective_date location_levels.delete_location_level( location_level_id=TEST_LEVEL_ID, office_id=TEST_OFFICE, effective_date=temp_effective_date, ) - # Try to get it, should raise or return None/empty + # CDA may return the previous effective level after this dated level is deleted. try: level = location_levels.get_location_level( level_id=TEST_LEVEL_ID, @@ -124,9 +132,10 @@ def test_delete_loc_level(): effective_date=temp_effective_date, unit=TEST_UNIT, ) - assert level.df.empty - except Exception: - pass + except ApiError as error: + assert error.response.status_code == 404 + else: + assert pd.to_datetime(level.json["level-date"]) != temp_effective_date def test_get_loc_level_ts(): diff --git a/tests/cda/levels/specified_levels_cda_test.py b/tests/cda/levels/specified_levels_cda_test.py index aef579aa..a2d79b46 100644 --- a/tests/cda/levels/specified_levels_cda_test.py +++ b/tests/cda/levels/specified_levels_cda_test.py @@ -97,11 +97,7 @@ def test_delete_specified_level(): specified_levels.delete_specified_level( specified_level_id=temp_id, office_id=TEST_OFFICE ) - # Try to get it, should raise or return None/empty - try: - levels = specified_levels.get_specified_levels( - specified_level_mask=temp_id, office_id=TEST_OFFICE - ) - assert not any(lvl.get("id") == temp_id for lvl in levels.json) - except Exception: - pass + levels = specified_levels.get_specified_levels( + specified_level_mask=temp_id, office_id=TEST_OFFICE + ) + assert not any(lvl.get("id") == temp_id for lvl in levels.json)