Skip to content

Commit

Permalink
Configure Pytests on Feature Flags (#764)
Browse files Browse the repository at this point in the history
### Feature or Bugfix
<!-- please choose -->
- Bugfix

### Detail
- Move `tests/modules/test_loader.py` to `tests/base/test_loader.py` as
originally the test_loader tests were being excluded because of the
`ignore_module_tests_if_not_active()` function in `tests/conftests.py`

- Added `@pytest.mark.skipif(...)` decorators to skip tests if the
module features are not enabled in `config.json`
- Originally this was failing on some of the `test_dataset_location.py`
tests when `modules.datasets.features.file_actions` was set to `False`
in `config.json`

### Relates

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

N/A
```
- Does this PR introduce or modify any input fields or queries - this includes
fetching data from storage outside the application (e.g. a database, an S3 bucket)?
  - Is the input sanitized?
  - What precautions are you taking before deserializing the data you consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires authorization?
  - How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?
```

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
noah-paige authored Sep 18, 2023
1 parent 4f742cf commit 74da2ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/modules/datasets/test_dataset_location.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import MagicMock
import pytest

from dataall.base.config import config
from dataall.modules.datasets_base.db.dataset_models import Dataset

@pytest.fixture(scope='module')
Expand All @@ -10,6 +11,7 @@ def dataset1(env_fixture, org_fixture, dataset, group) -> Dataset:
)


@pytest.mark.skipif(not config.get_property("modules.datasets.features.file_actions"), reason="Feature Disabled by Config")
def test_create_location(client, dataset1, user, group, patch_es, module_mocker):
mock_client = MagicMock()
module_mocker.patch("dataall.modules.datasets.services.dataset_location_service.S3LocationClient", mock_client)
Expand Down Expand Up @@ -39,6 +41,7 @@ def test_create_location(client, dataset1, user, group, patch_es, module_mocker)
assert 'test' in response.data.createDatasetStorageLocation.tags


@pytest.mark.skipif(not config.get_property("modules.datasets.features.file_actions"), reason="Feature Disabled by Config")
def test_manage_dataset_location(client, dataset1, user, group):
response = client.query(
"""
Expand Down

0 comments on commit 74da2ad

Please sign in to comment.