Skip to content

Commit

Permalink
Align existing tests with v4
Browse files Browse the repository at this point in the history
  • Loading branch information
alarthast committed Oct 4, 2024
1 parent a77c392 commit 82e2182
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
29 changes: 9 additions & 20 deletions tests/fixtures/valid_yaml/project.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
version: '3.0'

expectations:
population_size: 100
version: '4.0'

actions:
generate_cohort:
run: cohortextractor:latest generate_cohort
outputs:
highly_sensitive:
cohort: output/input.csv

generate_cohort_with_dummy_data:
# we provide --output-dir here to distinguish the action from the one above
run: cohortextractor:latest generate_cohort --output-dir output/extra
dummy_data_file: test-data/dummy-data.csv
generate_dataset:
run: ehrql:v1 generate-dataset analysis/dataset_definition.py --output output/dataset.csv.gz
outputs:
highly_sensitive:
cohort: output/extra/input.csv
dataset: output/dataset.csv.gz

prepare_data_m:
run: python:latest python analysis/filter_by_sex.py M output/input.csv male.csv
needs: [generate_cohort]
needs: [generate_dataset]
outputs:
highly_sensitive:
male_cohort: male*.csv

prepare_data_f:
run: python:latest python analysis/filter_by_sex.py F output/input.csv female.csv
needs: [generate_cohort]
needs: [generate_dataset]
outputs:
highly_sensitive:
female_cohort: female*.csv

prepare_data_with_quote_in_filename:
run: python:latest python analysis/filter_by_sex.py F output/input.csv "qu'ote.csv"
needs: [generate_cohort]
needs: [generate_dataset]
outputs:
highly_sensitive:
quote_cohort: "qu'ote*.csv"
Expand All @@ -52,14 +41,14 @@ actions:
run: minimal-action:v1.1.0 output/input.csv
config:
suffix: .backup
needs: [generate_cohort]
needs: [generate_dataset]
outputs:
highly_sensitive:
cohort: output/input.backup.csv

test_cancellation:
run: python:latest python analysis/filter_by_sex.py F output/input.csv somefile.csv
needs: [generate_cohort]
needs: [generate_dataset]
outputs:
highly_sensitive:
somefile: somefile.csv
14 changes: 6 additions & 8 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

def test_success():
data = {
"version": "3",
"expectations": {"population_size": 10},
"version": "4",
"actions": {
"action1": {
"run": "test:latest",
"outputs": {
"moderately_sensitive": {"cohort": "output.csv"},
"moderately_sensitive": {"dataset": "output.csv"},
},
},
},
Expand Down Expand Up @@ -169,7 +168,7 @@ def test_expectations_before_v3_has_a_default_set():
assert config.expectations.population_size == 1000


def test_expectations_exists():
def test_expectations_exists_for_v3():
# our logic for this is custom so ensure it works as expected
data = {
"version": 3,
Expand All @@ -186,7 +185,7 @@ def test_expectations_exists():
Pipeline.build(**data)


def test_expectations_population_size_exists():
def test_expectations_population_size_exists_for_v3():
data = {
"version": 3,
"expectations": {},
Expand All @@ -203,7 +202,7 @@ def test_expectations_population_size_exists():
Pipeline.build(**data)


def test_expectations_population_size_is_a_number():
def test_expectations_population_size_is_a_number_for_v3():
data = {
"version": 3,
"expectations": {"population_size": "test"},
Expand All @@ -225,8 +224,7 @@ def test_pipeline_all_actions(test_file):
config = load_pipeline(test_file)

assert config.all_actions == [
"generate_cohort",
"generate_cohort_with_dummy_data",
"generate_dataset",
"prepare_data_m",
"prepare_data_f",
"prepare_data_with_quote_in_filename",
Expand Down

0 comments on commit 82e2182

Please sign in to comment.