Skip to content

Commit

Permalink
Merge pull request openedx#116 from saraburns1/saraburns1_dbt_tests_p…
Browse files Browse the repository at this point in the history
…art2

test: dbt test followup
  • Loading branch information
Ian2012 authored Aug 15, 2024
2 parents c855dc6 + a3eeb53 commit 4aabd90
Show file tree
Hide file tree
Showing 11 changed files with 1,788 additions and 1,632 deletions.
2 changes: 1 addition & 1 deletion models/video/subsection_video_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ with
item_count,
subsection_block_id
)
select org, course_key, actor_id, subsection_block_id, engagement_level
select distinct org, course_key, actor_id, subsection_block_id, engagement_level
from subsection_counts
57 changes: 18 additions & 39 deletions models/video/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,24 @@ unit_tests:
rows: |
select * from section_video_engagement_expected
# - name: test_subsection_video_engagement
# model: subsection_video_engagement
# config:
# tags: 'ci'
# given:
# - input: ref('fact_video_plays')
# format: sql
# rows: |
# select * from fact_video_plays
# - input: ref('int_videos_per_subsection')
# format: sql
# rows: |
# select * from int_videos_per_subsection
# expect:
# format: sql
# rows: |
# select * from subsection_video_engagement_expected

# - name: test_fact_watched_video_segments
# model: fact_watched_video_segments
# config:
# tags: 'ci'
# given:
# - input: ref('video_playback_events')
# format: sql
# rows: |
# select * from video_playback_events
# - input: ref('dim_course_blocks_extended')
# format: sql
# rows: |
# select * from dim_course_blocks_extended
# - input: ref('dim_user_pii')
# format: sql
# rows: |
# select * from dim_user_pii
# expect:
# format: sql
# rows: |
# select * from fact_watched_video_segments_expected
- name: test_subsection_video_engagement
model: subsection_video_engagement
config:
tags: 'ci'
given:
- input: ref('fact_video_plays')
format: sql
rows: |
select * from fact_video_plays
- input: ref('int_videos_per_subsection')
format: sql
rows: |
select * from int_videos_per_subsection
expect:
format: sql
rows: |
select * from subsection_video_engagement_expected
order by org, course_key, subsection_block_id, actor_id
- name: test_fact_video_engagement
model: fact_video_engagement
Expand Down
7 changes: 0 additions & 7 deletions tests/get_problem_id.sql

This file was deleted.

File renamed without changes.
88 changes: 88 additions & 0 deletions tests/macros/get_bucket.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
select 0.95 as field
from system.one
where
{{ get_bucket('field') }} != '90-100%'

union all

select 0.8 as field
from system.one
where
{{ get_bucket('field') }} != '80-89%'

union all

select 0.700009 as field
from system.one
where
{{ get_bucket('field') }} != '70-79%'

union all

select 0.69999 as field
from system.one
where
{{ get_bucket('field') }} != '60-69%'

union all

select 0.5 as field
from system.one
where
{{ get_bucket('field') }} != '50-59%'

union all

select 0.4123 as field
from system.one
where
{{ get_bucket('field') }} != '40-49%'

union all

select 0.3000000000 as field
from system.one
where
{{ get_bucket('field') }} != '30-39%'

union all

select 0.276734 as field
from system.one
where
{{ get_bucket('field') }} != '20-29%'

union all

select 0.11111 as field
from system.one
where
{{ get_bucket('field') }} != '10-19%'

union all

select 0.0342 as field
from system.one
where
{{ get_bucket('field') }} != '0-9%'

union all

select 0.00000005 as field
from system.one
where
{{ get_bucket('field') }} != '0-9%'

union all

select -0.1 as field
from system.one
where
{{ get_bucket('field') }} != '0-9%'

union all

select 123 as field
from system.one
where
{{ get_bucket('field') }} != '90-100%'
57 changes: 57 additions & 0 deletions tests/macros/get_problem_id.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
select
'http://local.edly.io:8000/xblock/block-v1:edunext+demo+demo+ccx+type@problem+block@3c1646f7133a4c5fb4557d649e22c251'
as object_id
from system.one
where
{{ get_problem_id("object_id") }}
!= 'block-v1:edunext+demo+demo+ccx+type@problem+block@3c1646f7133a4c5fb4557d649e22c251'

union all

select
'http://localhost:18000/course/course-v1:Org1+DemoX+1937e7'
as object_id
from system.one
where
{{ get_problem_id("object_id") }}
!= ''

union all

select
'http://localhost:18000/xblock/block-v1:course-v1:Org0+DemoX+2bc51b+type@problem+block@09b07a8d'
as object_id
from system.one
where
{{ get_problem_id("object_id") }}
!= 'block-v1:course-v1:Org0+DemoX+2bc51b+type@problem+block@09b07a8d'

union all

select
'http://localhost:18000/xblock/block-v1:course-v1:Org0+DemoX+2bc51b+type@problem+block@09b07a8d/answer'
as object_id
from system.one
where
{{ get_problem_id("object_id") }}
!= 'block-v1:course-v1:Org0+DemoX+2bc51b+type@problem+block@09b07a8d'

union all

select
'http://localhost:18000/xblock/block-v1:course-v1:Org0+DemoX+81bba1+type@problem+block@20d3f709/hint/1'
as object_id
from system.one
where
{{ get_problem_id("object_id") }}
!= 'block-v1:course-v1:Org0+DemoX+81bba1+type@problem+block@20d3f709'

union all

select
'http://localhost:18000/xblock/block-v1:course-v1:Org0+DemoX+81bba1+type@problem+block@20d3f709/hint/1'
as object_id
from system.one
where
{{ get_problem_id("object_id") }}
!= 'block-v1:course-v1:Org0+DemoX+81bba1+type@problem+block@20d3f709'
File renamed without changes.
33 changes: 33 additions & 0 deletions tests/macros/section_from_display.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
select
'1:2:3 - Course 1a2b3c' as display_name_with_location
from system.one
where
{{ section_from_display('display_name_with_location') }}
!= '1:0:0'

union all

select
'1:2:33 - Video 12' as display_name_with_location
from system.one
where
{{ section_from_display('display_name_with_location') }}
!= '1:0:0'

union all

select
'1:22:3 - Vertical 345' as display_name_with_location
from system.one
where
{{ section_from_display('display_name_with_location') }}
!= '1:0:0'

union all

select
'11:2:3 - Sequential 678' as display_name_with_location
from system.one
where
{{ section_from_display('display_name_with_location') }}
!= '11:0:0'
33 changes: 33 additions & 0 deletions tests/macros/subsection_from_display.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
select
'1:2:3 - Chapter 123' as display_name_with_location
from system.one
where
{{ subsection_from_display('display_name_with_location') }}
!= '1:2:0'

union all

select
'1:2:33 - Problem 456' as display_name_with_location
from system.one
where
{{ subsection_from_display('display_name_with_location') }}
!= '1:2:0'

union all

select
'1:22:3 - Sequential 789' as display_name_with_location
from system.one
where
{{ subsection_from_display('display_name_with_location') }}
!= '1:22:0'

union all

select
'11:2:3 - Vertical 123' as display_name_with_location
from system.one
where
{{ subsection_from_display('display_name_with_location') }}
!= '11:2:0'
2 changes: 1 addition & 1 deletion unit-test-seeds/event_sink/user_profile.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,user_id,name,email,meta,coursewhere,language,location,year_of_birth,gender,level_of_education,mailing_address,city,country,state,goals,bio,profile_image_uploaded_at,phone_number,dumnp_id,time_last_dumped
id,user_id,name,email,meta,courseware,language,location,year_of_birth,gender,level_of_education,mailing_address,city,country,state,goals,bio,profile_image_uploaded_at,phone_number,dump_id,time_last_dumped
0,0,Actor 0,[email protected],{},,,,1907,,none,,,CO,,,,,,cc0a7018-7bc3-4288-8c17-842d5541d9c9,2024-07-10 19:58:24.114194
1,1,Actor 1,[email protected],{},,,,1979,f,b,,,CO,,,,,,0b32ffab-885a-4756-bffa-a0e2d8271855,2024-07-10 19:58:24.114212
2,2,Actor 2,[email protected],{},,,,2002,o,b,,,US,,,,,,f508e40f-44b5-4fdd-ab06-365004898ff8,2024-07-10 19:58:24.114222
Expand Down
Loading

0 comments on commit 4aabd90

Please sign in to comment.