Skip to content

Commit

Permalink
Merge branch 'main' into diff/ops/C1442068507-GES_DISC
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesfwood authored Oct 7, 2024
2 parents 9afac83 + 369da4d commit bdbcbff
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 7 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ jobs:
run: |
echo "test_env=$(python -c "print('${{ github.head_ref }}'.split('/')[1])")" >> $GITHUB_OUTPUT
echo "concept_id=$(python -c "print('${{ github.head_ref }}'.split('/')[2])")" >> $GITHUB_OUTPUT
- name: install
id: install
run: |
poetry install
- name: Execute tests
id: run-tests
working-directory: tests
env:
TEST_ENV: ${{ steps.get-env-ccid.outputs.test_env }}
CONCEPT_ID: ${{ steps.get-env-ccid.outputs.concept_id }}
CMR_USER: ${{ secrets.CMR_USER }}
CMR_PASS: ${{ secrets.CMR_PASS }}
run: |
poetry install
poetry run pytest tests/verify_collection.py --concept_id $CONCEPT_ID --env $TEST_ENV --junitxml=$GITHUB_WORKSPACE/test-results/test_report.xml --html=$GITHUB_WORKSPACE/test-results/test_report.html || true
poetry run pytest verify_collection.py --concept_id $CONCEPT_ID --env $TEST_ENV --junitxml=$GITHUB_WORKSPACE/test-results/test_report.xml --html=$GITHUB_WORKSPACE/test-results/test_report.html || true
- name: Publish Test Results
id: publish-test
uses: EnricoMi/publish-unit-test-result-action@v2
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
failed.extend([list(failed.keywords)[3] for failed in terminalreporter.stats.get('failed', [])])
success.extend([list(passed.keywords)[3] for passed in terminalreporter.stats.get('passed', [])])

# Have temporal and spacial test if failed either one don't put in success
# Have temporal and spatial test if failed either one don't put in success

# Convert lists to sets
fail_set = set(failed)
Expand Down
2 changes: 1 addition & 1 deletion tests/get_associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_associations(token, env):
}

service_concept_id = cmr.queries.ServiceQuery(mode=mode).provider('POCLOUD').name('PODAAC L2 Cloud Subsetter').get()[0].get('concept_id')
url = cmr.queries.CollectionQuery(mode=mode).service_concept_id(service_concept_id).provider('POCLOUD')._build_url()
url = cmr.queries.CollectionQuery(mode=mode).service_concept_id(service_concept_id)._build_url()
collections_query = requests.get(url, headers=headers, params={'page_size': 2000}).json()['feed']['entry']
collections = [a.get('id') for a in collections_query]

Expand Down
Empty file added tests/skip/skip_spatial_ops.csv
Empty file.
Empty file added tests/skip/skip_spatial_uat.csv
Empty file.
2 changes: 2 additions & 0 deletions tests/skip/skip_temporal_ops.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C2036882456-POCLOUD
C2205121315-POCLOUD
2 changes: 2 additions & 0 deletions tests/skip/skip_temporal_uat.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C1238658389-POCLOUD
C1238658392-POCLOUD
32 changes: 29 additions & 3 deletions tests/verify_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pytest
import requests
import xarray
import csv

from requests.auth import HTTPBasicAuth

Expand Down Expand Up @@ -53,6 +54,25 @@ def request_session():
yield s


# Helper function to read a single CSV file and return a set of skip entries
def read_skip_list(csv_file):
with open(csv_file, newline='') as f:
reader = csv.reader(f)
return {row[0].strip() for row in reader}


# Fixture for the first skip list (skip_collections1.csv)
@pytest.fixture(scope="session")
def skip_temporal(env):
return read_skip_list(f"skip/skip_temporal_{env}.csv")


# Fixture for the second skip list (skip_collections2.csv)
@pytest.fixture(scope="session")
def skip_spatial(env):
return read_skip_list(f"skip/skip_spatial_{env}.csv")


@pytest.fixture(scope="session")
def bearer_token(env: str, request_session: requests.Session) -> str:
tokens = []
Expand Down Expand Up @@ -367,9 +387,12 @@ def find_variable(ds, var_name):

@pytest.mark.timeout(600)
def test_spatial_subset(collection_concept_id, env, granule_json, collection_variables,
harmony_env, tmp_path: pathlib.Path, bearer_token):
harmony_env, tmp_path: pathlib.Path, bearer_token, skip_spatial):
test_spatial_subset.__doc__ = f"Verify spatial subset for {collection_concept_id} in {env}"

if collection_concept_id in skip_spatial:
pytest.skip(f"Known collection to skip for spatial testing {collection_concept_id}")

logging.info("Using granule %s for test", granule_json['meta']['concept-id'])

# Compute a box that is smaller than the granule extent bounding box
Expand Down Expand Up @@ -523,8 +546,11 @@ def group_walk(groups, nc_d, current_group):

@pytest.mark.timeout(600)
def test_temporal_subset(collection_concept_id, env, granule_json, collection_variables,
harmony_env, tmp_path: pathlib.Path, bearer_token):
test_spatial_subset.__doc__ = f"Verify spatial subset for {collection_concept_id} in {env}"
harmony_env, tmp_path: pathlib.Path, bearer_token, skip_temporal):
test_spatial_subset.__doc__ = f"Verify temporal subset for {collection_concept_id} in {env}"

if collection_concept_id in skip_temporal:
pytest.skip(f"Known collection to skip for temporal testing {collection_concept_id}")

logging.info("Using granule %s for test", granule_json['meta']['concept-id'])

Expand Down

0 comments on commit bdbcbff

Please sign in to comment.