forked from rich-iannone/pointblank-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-game_revenue.R
135 lines (107 loc) · 2.73 KB
/
test-game_revenue.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Generated by pointblank
library(pointblank)
tbl <- pointblank::game_revenue
test_that("column `player_id` is of type: character", {
expect_col_is_character(
tbl,
columns = vars(player_id),
threshold = 1
)
})
test_that("column `session_id` is of type: character", {
expect_col_is_character(
tbl,
columns = vars(session_id),
threshold = 1
)
})
test_that("column `item_type` is of type: character", {
expect_col_is_character(
tbl,
columns = vars(item_type),
threshold = 1
)
})
test_that("column `item_name` is of type: character", {
expect_col_is_character(
tbl,
columns = vars(item_name),
threshold = 1
)
})
test_that("column `item_revenue` is of type: numeric", {
expect_col_is_numeric(
tbl,
columns = vars(item_revenue),
threshold = 1
)
})
test_that("values in `item_revenue` should be between `0.004` and `142.989`", {
expect_col_vals_between(
tbl,
columns = vars(item_revenue),
left = 0.004,
right = 142.989,
threshold = 0.1
)
})
test_that("column `session_duration` is of type: numeric", {
expect_col_is_numeric(
tbl,
columns = vars(session_duration),
threshold = 1
)
})
test_that("values in `session_duration` should be between `3.2` and `41`", {
expect_col_vals_between(
tbl,
columns = vars(session_duration),
left = 3.2,
right = 41,
threshold = 0.1
)
})
test_that("column `acquisition` is of type: character", {
expect_col_is_character(
tbl,
columns = vars(acquisition),
threshold = 1
)
})
test_that("column `country` is of type: character", {
expect_col_is_character(
tbl,
columns = vars(country),
threshold = 1
)
})
test_that("values in `country` should be in the set of `Germany`, `Canada`, `South Korea` (and 20 more)", {
expect_col_vals_in_set(
tbl,
columns = vars(country),
set = c("Germany", "Canada", "South Korea", "Sweden", "Austria", "Hong Kong", "United States", "Mexico", "Egypt", "Denmark", "Norway", "Japan", "Australia", "South Africa", "Spain", "France", "Portugal", "Russia", "India", "Switzerland", "China", "Philippines", "United Kingdom"),
threshold = 0.1
)
})
test_that("entirely distinct rows across all columns", {
expect_rows_distinct(tbl)
})
test_that("column schemas match", {
expect_col_schema_match(
tbl,
schema = col_schema(
player_id = "character",
session_id = "character",
session_start = c("POSIXct", "POSIXt"),
time = c("POSIXct", "POSIXt"),
item_type = "character",
item_name = "character",
item_revenue = "numeric",
session_duration = "numeric",
start_day = "Date",
acquisition = "character",
country = "character"
),
threshold = 1
)
})