Skip to content

Commit

Permalink
Merge pull request #104 from saraburns1/saraburns1_datatest_maint
Browse files Browse the repository at this point in the history
test: Fix data tests
  • Loading branch information
bmtcril authored Jun 20, 2024
2 parents f9356d5 + d18f6c1 commit aa58bd7
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 72 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
tutor local start -d
tutor local do init -l aspects
tutor local do load-xapi-test-data
- name: Check dbt tests
run: |
dbt run
dbt test
- name: Check docs coverage
run: |
dbt run
Expand Down
4 changes: 2 additions & 2 deletions models/enrollment/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ models:
description: "The mode of enrollment"
- name: enrollment_status
description: "Whether a learner is actively enrolled in a course"
tests:
data_tests:
- accepted_values:
values: ["registered", "unregistered"]
data_type: String
Expand Down Expand Up @@ -84,7 +84,7 @@ models:
- name: enrollment_status
data_type: string
description: "Whether a learner is actively enrolled in a course"
tests:
data_tests:
- accepted_values:
values: ["registered", "unregistered"]
- name: enrollment_mode
Expand Down
6 changes: 3 additions & 3 deletions models/grading/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ models:
description: "The entity's display name with section, subsection, and unit prepended to the name. This provides additional context when looking at block names and can help data consumers understand which block they are analyzing"
- name: grade_type
description: "The type of object graded"
tests:
data_tests:
- accepted_values:
values: ["course", "subsection", "problem"]
data_type: Nullable(String)
Expand Down Expand Up @@ -91,7 +91,7 @@ models:
- name: approving_state
data_type: string
description: "The most recent approving_state of the learner's grade"
tests:
data_tests:
- accepted_values:
values: ["passed", "failed"]

Expand Down Expand Up @@ -149,7 +149,7 @@ models:
description: "The mode of enrollment"
- name: enrollment_status
description: "Whether a learner is actively enrolled in a course"
tests:
data_tests:
- accepted_values:
values: ["registered", "unregistered"]
- name: course_grade
Expand Down
5 changes: 3 additions & 2 deletions models/instance/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ models:
- name: enrollment_status
data_type: string
description: "The type of enrollment event (ex: registered, unregistered)"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values: [ "registered", "unregistered" ]
table: 'xapi.fact_instance_enrollments'
- name: course_enrollment_mode_status_cnt
data_type: int
description: "The number of enrollment events for this mode that occurred in the given hour"
2 changes: 1 addition & 1 deletion models/learners/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ models:
description: "The mode of enrollment"
- name: enrollment_status
description: "Whether a learner is actively enrolled in a course"
tests:
data_tests:
- accepted_values:
values: ["registered", "unregistered"]
- name: course_grade
Expand Down
20 changes: 11 additions & 9 deletions models/navigation/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ models:
- name: rollup_name
data_type: string
description: "The level at which page views are counted"
tests:
data_tests:
- accepted_values:
values: ["section", "subsection"]
- name: block_name
Expand Down Expand Up @@ -234,7 +234,7 @@ models:
- name: content_level
data_type: string
description: "The level at which page views are counted"
tests:
data_tests:
- accepted_values:
values: ["section", "subsection"]
- name: actor_id
Expand Down Expand Up @@ -287,12 +287,13 @@ models:
- name: engagement_level
data_type: string
description: "The engagement level of the learner with the section"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values:
- 'No problems attempted yet'
- 'All problems attempted'
- 'At least one problem attempted'
- 'No pages viewed yet'
- 'All pages viewed'
- 'At least one page viewed'
table: 'xapi.section_page_engagement'

- name: subsection_page_engagement
description: "A record per course per subsection per learner with their engagement level"
Expand All @@ -312,9 +313,10 @@ models:
- name: engagement_level
data_type: string
description: "The engagement level of the learner with the subsection"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values:
- 'No pages viewed yet'
- 'All pages viewed'
- 'At least one page viewed'
table: 'xapi.subsection_page_engagement'
16 changes: 9 additions & 7 deletions models/problems/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ models:
description: "The xAPI actor identifier"
- name: success
description: "The result of the last submission"
tests:
data_tests:
- not_null
data_type: Bool
- name: attempts
description: "The number of attempts made"
tests:
data_tests:
- not_null
data_type: Int16
- name: num_hints_displayed
Expand Down Expand Up @@ -361,7 +361,7 @@ models:
- name: section_subsection_problem_engagement
data_type: string
description: "The engagement level of the learner with the section/subsection"
tests:
data_tests:
- accepted_values:
values:
- 'No problems attempted yet'
Expand Down Expand Up @@ -488,12 +488,13 @@ models:
- name: engagement_level
data_type: string
description: "The engagement level of the learner with the section"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values:
- 'No problems attempted yet'
- 'All problems attempted'
- 'At least one problem attempted'
table: 'xapi.section_problem_engagement'

- name: subsection_problem_engagement
description: "A record per course per subsection per learner with their engagement level"
Expand All @@ -513,9 +514,10 @@ models:
- name: engagement_level
data_type: string
description: "The engagement level of the learner with the subsection"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values:
- 'No problems attempted yet'
- 'All problems attempted'
- 'At least one problem attempted'
table: 'xapi.subsection_problem_engagement'
51 changes: 8 additions & 43 deletions models/video/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ models:
- name: content_level
data_type: string
description: "The content level of the video"
tests:
data_tests:
- accepted_values:
values:
- 'section'
Expand All @@ -236,7 +236,7 @@ models:
- name: section_subsection_video_engagement
data_type: string
description: "The engagement level of the learner with the video"
tests:
data_tests:
- accepted_values:
values:
- 'No videos viewed yet'
Expand Down Expand Up @@ -326,12 +326,13 @@ models:
- name: engagement_level
data_type: string
description: "The engagement level of the learner with the section"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values:
- 'No videos viewed yet'
- 'All videos viewed'
- 'At least one video viewed'
table: 'xapi.section_video_engagement'

- name: subsection_video_engagement
description: "A record per course per subsection per learner with their engagement level"
Expand All @@ -351,46 +352,10 @@ models:
- name: engagement_level
data_type: string
description: "The engagement level of the learner with the subsection"
tests:
- accepted_values:
data_tests:
- accepted_values_xapi:
values:
- 'No videos viewed yet'
- 'All videos viewed'
- 'At least one video viewed'

- name: watched_video_segments
description: "A dataset with one record per learner per video segment watched in a course"
columns:
- name: org
data_type: string
description: "The organization that the course belongs to"
- name: course_key
data_type: string
description: "The course key for the course"
- name: actor_id
data_type: string
description: "The xAPI actor identifier"
- name: video_id
data_type: string
description: "The xAPI object identifier"
- name: start_position
data_type: int64
description: "The start position of the segment"
- name: end_position
data_type: int64
description: "The end position of the segment"
- name: started_at
data_type: datetime
description: "The time the video segment was started"
- name: ended_at
data_type: datetime
description: "The time the video segment was ended"
- name: emission_time
data_type: datetime
description: "The time the event was emitted"
- name: end_type
data_type: string
description: "The type of event that ended the video segment"
- name: video_duration
data_type: int64
description: "The duration of the video in seconds"
table: 'xapi.subsection_video_engagement'
10 changes: 5 additions & 5 deletions package-lock.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packages:
- package: dbt-labs/codegen
version: 0.11.0
- package: dbt-labs/dbt_utils
version: 1.1.0
sha1_hash: 97b4306bc75da556cd002412ddf08f036472221b
- package: dbt-labs/codegen
version: 0.12.1
- package: dbt-labs/dbt_utils
version: 1.1.1
sha1_hash: d974113b0f072cce35300077208f38581075ab40
34 changes: 34 additions & 0 deletions tests/generic/test_accepted_values_xapi.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% test accepted_values_xapi(model, column_name, values, table, quote=True) %}

with all_values as (

select distinct
{{ column_name }} as value_field

from {{ table }}

),

validation_errors as (

select
value_field

from all_values
where value_field not in (
{% for value in values -%}
{% if quote -%}
'{{ value }}'
{%- else -%}
{{ value }}
{%- endif -%}
{%- if not loop.last -%},{%- endif %}
{%- endfor %}
)

)

select *
from validation_errors

{% endtest %}

0 comments on commit aa58bd7

Please sign in to comment.