|
| 1 | +# features/cli/bulk_upload_water_levels.feature |
| 2 | + |
| 3 | +@cli |
| 4 | +@backend |
| 5 | +@BDMS-TBD |
| 6 | +Feature: Bulk upload water level entries from CSV via CLI |
| 7 | + As a hydrogeologist or data specialist |
| 8 | + I want to upload a CSV file containing water level entry data for multiple wells using a CLI command |
| 9 | + So that water level records can be created efficiently and accurately in the system |
| 10 | + |
| 11 | +# Background: |
| 12 | +# Given the CLI binary "bdms" is installed and available on the PATH |
| 13 | +# And I have a valid CLI configuration for the target environment |
| 14 | +# And valid lexicon values exist for: |
| 15 | +# | lexicon category | |
| 16 | +# | sample_method | |
| 17 | +# | level_status | |
| 18 | +# | data_quality | |
| 19 | + |
| 20 | + @positive @happy_path @BDMS-TBD @cleanup_samples |
| 21 | + Scenario: Uploading a valid water level entry CSV containing required and optional fields |
| 22 | + Given a valid CSV file for bulk water level entry upload |
| 23 | + And my CSV file is encoded in UTF-8 and uses commas as separators |
| 24 | + And my CSV file contains multiple rows of water level entry data |
| 25 | + And the water level CSV includes required fields: |
| 26 | + | required field name | |
| 27 | + | field_staff | |
| 28 | + | well_name_point_id | |
| 29 | + | field_event_date_time | |
| 30 | + | measuring_person | |
| 31 | + And each "well_name_point_id" value matches an existing well |
| 32 | + And "field_event_date_time" values are valid ISO 8601 timezone-naive datetime strings (e.g. "2025-02-15T08:00:00") |
| 33 | + And "water_level_date_time" values are valid ISO 8601 timezone-naive datetime strings (e.g. "2025-02-15T10:30:00") |
| 34 | + And when provided, "sample_method", "level_status", and "data_quality" values are valid lexicon values |
| 35 | + And the CSV includes optional fields when available: |
| 36 | + | optional field name | |
| 37 | + | field_staff_2 | |
| 38 | + | field_staff_3 | |
| 39 | + | water_level_date_time | |
| 40 | + | sample_method | |
| 41 | + | mp_height | |
| 42 | + | level_status | |
| 43 | + | depth_to_water_ft | |
| 44 | + | data_quality | |
| 45 | + | water_level_notes | |
| 46 | + When I run the CLI command: |
| 47 | + """ |
| 48 | + oco water-levels bulk-upload --file ./water_levels.csv --output json |
| 49 | + """ |
| 50 | + Then the command exits with code 0 |
| 51 | + And stdout should be valid JSON |
| 52 | + And stdout includes a summary containing: |
| 53 | + | summary_field | value | |
| 54 | + | total_rows_processed | 2 | |
| 55 | + | total_rows_imported | 2 | |
| 56 | + | validation_errors_or_warnings | 0 | |
| 57 | + And stdout includes an array of created water level entry objects |
| 58 | + And stderr should be empty |
| 59 | + |
| 60 | + @positive @validation @column_order @BDMS-TBD @cleanup_samples |
| 61 | + Scenario: Upload succeeds when required columns are present but in a different order |
| 62 | + Given my water level CSV file contains all required headers but in a different column order |
| 63 | + And the CSV includes required fields: |
| 64 | + | required field name | |
| 65 | + | field_staff | |
| 66 | + | well_name_point_id | |
| 67 | + | field_event_date_time | |
| 68 | + | measuring_person | |
| 69 | + When I run the CLI command: |
| 70 | + """ |
| 71 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 72 | + """ |
| 73 | + # assumes users are entering datetimes as Mountain Time because well location is restricted to New Mexico |
| 74 | + Then all datetime objects are assigned the correct Mountain Time timezone offset based on the date value. |
| 75 | + And the command exits with code 0 |
| 76 | + And all water level entries are imported |
| 77 | + And stderr should be empty |
| 78 | + |
| 79 | + @positive @validation @extra_columns @BDMS-TBD @cleanup_samples |
| 80 | + Scenario: Upload succeeds when CSV contains extra, unknown columns |
| 81 | + Given my water level CSV file contains extra columns but is otherwise valid |
| 82 | + When I run the CLI command: |
| 83 | + """ |
| 84 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 85 | + """ |
| 86 | + Then the command exits with code 0 |
| 87 | + And all water level entries are imported |
| 88 | + And stderr should be empty |
| 89 | + |
| 90 | + ########################################################################### |
| 91 | + # NEGATIVE VALIDATION SCENARIOS |
| 92 | + ########################################################################### |
| 93 | + |
| 94 | + @negative @validation @BDMS-TBD |
| 95 | + Scenario: No water level entries are imported when any row fails validation |
| 96 | + Given my water level CSV contains 3 rows with 2 valid rows and 1 row missing the required "well_name_point_id" |
| 97 | + When I run the CLI command: |
| 98 | + """ |
| 99 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 100 | + """ |
| 101 | + Then the command exits with a non-zero exit code |
| 102 | + And stderr should contain a validation error for the row missing "well_name_point_id" |
| 103 | + And no water level entries are imported |
| 104 | + |
| 105 | + @negative @validation @required_fields @BDMS-TBD |
| 106 | + Scenario Outline: Upload fails when a required field is missing |
| 107 | + Given my water level CSV file contains a row missing the required "<required_field>" field |
| 108 | + When I run the CLI command: |
| 109 | + """ |
| 110 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 111 | + """ |
| 112 | + Then the command exits with a non-zero exit code |
| 113 | + And stderr should contain a validation error for the "<required_field>" field |
| 114 | + And no water level entries are imported |
| 115 | + |
| 116 | + Examples: |
| 117 | + | required_field | |
| 118 | + | field_staff | |
| 119 | + | well_name_point_id | |
| 120 | + | field_event_date_time | |
| 121 | + | measuring_person | |
| 122 | + |
| 123 | + @negative @validation @date_formats @BDMS-TBD |
| 124 | + Scenario: Upload fails due to invalid date formats |
| 125 | + Given my CSV file contains invalid ISO 8601 date values in the "water_level_date_time" field |
| 126 | + When I run the CLI command: |
| 127 | + """ |
| 128 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 129 | + """ |
| 130 | + Then the command exits with a non-zero exit code |
| 131 | + And stderr should contain validation errors identifying the invalid field and row |
| 132 | + And no water level entries are imported |
| 133 | + |
| 134 | + @negative @validation @numeric_fields @BDMS-TBD |
| 135 | + Scenario: Upload fails due to invalid numeric fields |
| 136 | + Given my CSV file contains values that cannot be parsed as numeric in numeric-required fields such as "mp_height" or "depth_to_water_ft" |
| 137 | + When I run the CLI command: |
| 138 | + """ |
| 139 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 140 | + """ |
| 141 | + Then the command exits with a non-zero exit code |
| 142 | + And stderr should contain validation errors identifying the invalid field and row |
| 143 | + And no water level entries are imported |
| 144 | + |
| 145 | + @negative @validation @lexicon_values @BDMS-TBD |
| 146 | + Scenario: Upload fails due to invalid lexicon values for water level descriptor fields |
| 147 | + Given my CSV file contains invalid lexicon values for "sample_method", "level_status", or "data_quality" |
| 148 | + When I run the CLI command: |
| 149 | + """ |
| 150 | + oco water-levels bulk-upload --file ./water_levels.csv |
| 151 | + """ |
| 152 | + Then the command exits with a non-zero exit code |
| 153 | + And stderr should contain validation errors identifying the invalid field and row |
| 154 | + And no water level entries are imported |
0 commit comments