Skip to content

Commit c0b2540

Browse files
Fix Failing Test Cases
1 parent 93192fb commit c0b2540

File tree

6 files changed

+39
-113
lines changed

6 files changed

+39
-113
lines changed

tests/testthat/test-CustomFieldService.R

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,41 +52,31 @@ test_that("dfp_createCustomFieldOptions", {
5252
test_that("dfp_getCustomFieldOption", {
5353

5454
options(rdfp.network_code = rdfp_options$test_network_code)
55-
request_data <- list(dfp_createCustomFieldOptions_result$id[1])
56-
dfp_getCustomFieldOption_result <- dfp_getCustomFieldOption(request_data)
57-
58-
expect_is(dfp_getCustomFieldOption_result, "data.frame")
55+
request_data <- list(dfp_createCustomFieldOptions_result$id[1])
56+
dfp_getCustomFieldOption_result <- dfp_getCustomFieldOption(request_data)
57+
expect_is(dfp_getCustomFieldOption_result, "data.frame")
5958
options(rdfp.network_code = rdfp_options$network_code)
6059
})
6160

6261
test_that("dfp_getCustomFieldsByStatement", {
63-
6462
options(rdfp.network_code = rdfp_options$test_network_code)
6563
request_data <- list('filterStatement'=list('query'=paste0("WHERE name='Timing - ", myuuid, "'")))
66-
6764
dfp_getCustomFieldsByStatement_result <- dfp_getCustomFieldsByStatement(request_data)
68-
6965
expect_is(dfp_getCustomFieldsByStatement_result, "data.frame")
7066
options(rdfp.network_code = rdfp_options$network_code)
7167
})
7268

7369
test_that("dfp_updateCustomFieldOptions", {
74-
7570
options(rdfp.network_code = rdfp_options$test_network_code)
76-
7771
request_data <- data.frame(id=dfp_createCustomFieldOptions_result$id,
7872
customFieldId=rep(dfp_createCustomFields_result$id,3),
7973
displayName=c('Morning1', 'Afternoon1', 'Evening1'))
80-
8174
dfp_updateCustomFieldOptions_result <- dfp_updateCustomFieldOptions(request_data)
82-
8375
expect_is(dfp_updateCustomFieldOptions_result, "data.frame")
8476
options(rdfp.network_code = rdfp_options$network_code)
85-
8677
})
8778

8879
test_that("dfp_updateCustomFields", {
89-
9080
options(rdfp.network_code = rdfp_options$test_network_code)
9181
request_data <- data.frame(id=dfp_createCustomFields_result$id,
9282
name=paste0('Timing - ', myuuid, '2'),
@@ -100,11 +90,9 @@ test_that("dfp_updateCustomFields", {
10090
})
10191

10292
test_that("dfp_performCustomFieldAction", {
103-
10493
options(rdfp.network_code = rdfp_options$test_network_code)
10594
request_data <- list(customFieldAction='DeactivateCustomFields',
10695
filterStatement=list('query'=paste0("WHERE name = 'Timing - ", myuuid, "2'")))
107-
10896
dfp_performCustomFieldAction_result <- dfp_performCustomFieldAction(request_data)
10997
expect_is(dfp_performCustomFieldAction_result, "data.frame")
11098
expect_true(all(c('numChanges') %in% names(dfp_performCustomFieldAction_result)))
@@ -114,8 +102,7 @@ test_that("dfp_performCustomFieldAction", {
114102
request_data <- list('filterStatement'=
115103
list('query'=paste0("WHERE isActive=false and id=",
116104
dfp_createCustomFields_result$id)))
117-
dfp_getCustomFieldsByStatement_result <- dfp_getCustomFieldsByStatement(request_data, as_df=FALSE)
118-
expect_equal(length(dfp_getCustomFieldsByStatement_result), 1)
119-
105+
dfp_getCustomFieldsByStatement_result <- dfp_getCustomFieldsByStatement(request_data, as_df=TRUE)
106+
expect_equal(nrow(dfp_getCustomFieldsByStatement_result), 1)
120107
options(rdfp.network_code = rdfp_options$network_code)
121108
})

tests/testthat/test-CustomTargetingService.R

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,94 +23,74 @@ dfp_createCustomTargetingValues_result <- dfp_createCustomTargetingValues(reques
2323
options(rdfp.network_code = rdfp_options$network_code)
2424

2525
test_that("dfp_createCustomTargetingKeys", {
26-
2726
expect_is(dfp_createCustomTargetingKeys_result, "data.frame")
28-
expect_true(all(c('id', 'name', 'displayName', 'type', 'status') %in% names(dfp_createCustomTargetingKeys_result)))
29-
27+
expect_true(all(c('id', 'name', 'displayName', 'type', 'status') %in%
28+
names(dfp_createCustomTargetingKeys_result)))
3029
})
3130

3231
test_that("dfp_createCustomTargetingValues", {
33-
3432
expect_is(dfp_createCustomTargetingValues_result, "data.frame")
35-
expect_true(all(c('customTargetingKeyId', 'id', 'name', 'displayName', 'matchType', 'status') %in% names(dfp_createCustomTargetingValues_result)))
36-
33+
expect_true(all(c('customTargetingKeyId', 'id', 'name', 'displayName', 'matchType', 'status') %in%
34+
names(dfp_createCustomTargetingValues_result)))
3735
})
3836

3937
test_that("dfp_getCustomTargetingKeysByStatement", {
40-
4138
request_data <- list('filterStatement'=list('query'="WHERE name like 'Test%'"))
42-
4339
dfp_getCustomTargetingKeysByStatement_result <- dfp_getCustomTargetingKeysByStatement(request_data)
44-
4540
expect_is(dfp_getCustomTargetingKeysByStatement_result, "data.frame")
46-
4741
})
4842

4943
test_that("dfp_getCustomTargetingValuesByStatement", {
50-
5144
options(rdfp.network_code = rdfp_options$test_network_code)
52-
request_data <- list('filterStatement'=list('query'=paste0("WHERE customTargetingKeyId='",
53-
dfp_createCustomTargetingKeys_result$id,
54-
"' AND name like 'TestValue%'")))
55-
56-
dfp_getCustomTargetingValuesByStatement_result <- dfp_getCustomTargetingValuesByStatement(request_data)
57-
58-
expect_is(dfp_getCustomTargetingValuesByStatement_result, "data.frame")
45+
request_data <- list('filterStatement'=list('query'=paste0("WHERE customTargetingKeyId='",
46+
dfp_createCustomTargetingKeys_result$id,
47+
"' AND name like 'TestValue%'")))
48+
dfp_getCustomTargetingValuesByStatement_result <- dfp_getCustomTargetingValuesByStatement(request_data)
49+
expect_is(dfp_getCustomTargetingValuesByStatement_result, "data.frame")
5950
options(rdfp.network_code = rdfp_options$network_code)
60-
6151
})
6252

6353
test_that("dfp_updateCustomTargetingKeys", {
64-
6554
options(rdfp.network_code = rdfp_options$test_network_code)
6655
request_data <- list(keys=list(id=dfp_createCustomTargetingKeys_result$id,
6756
name='Test1',
6857
displayName='TestKey1A',
6958
type='FREEFORM'))
7059
dfp_updateCustomTargetingKeys_result <- dfp_updateCustomTargetingKeys(request_data)
71-
7260
expect_is(dfp_updateCustomTargetingKeys_result, "data.frame")
7361
options(rdfp.network_code = rdfp_options$network_code)
74-
7562
})
7663

7764
test_that("dfp_updateCustomTargetingValues", {
78-
7965
options(rdfp.network_code = rdfp_options$test_network_code)
8066
request_data <- data.frame(customTargetingKeyId=dfp_createCustomTargetingKeys_result$id,
8167
id=dfp_createCustomTargetingValues_result$id[1],
8268
name='TestValue1',
8369
displayName='TestValue1A',
8470
matchType='EXACT')
8571
dfp_updateCustomTargetingValues_result <- dfp_updateCustomTargetingValues(request_data)
86-
8772
expect_is(dfp_updateCustomTargetingValues_result, "data.frame")
8873
options(rdfp.network_code = rdfp_options$network_code)
89-
9074
})
9175

9276
test_that("dfp_performCustomTargetingValueAction", {
93-
9477
options(rdfp.network_code = rdfp_options$test_network_code)
9578
request_data <- list(customTargetingValueAction='DeleteCustomTargetingValues',
9679
filterStatement=list('query'=paste0("WHERE name like 'Test%'")))
9780
dfp_performCustomTargetingValueAction_result <- dfp_performCustomTargetingValueAction(request_data, as_df=FALSE)
98-
9981
expect_is(dfp_performCustomTargetingValueAction_result, "list")
100-
expect_length(dfp_performCustomTargetingValueAction_result, 1)
101-
expect_named(dfp_performCustomTargetingValueAction_result[[1]], c("numChanges"))
82+
expect_named(dfp_performCustomTargetingValueAction_result, "numChanges")
83+
expect_equal(as.integer(dfp_performCustomTargetingValueAction_result$numChanges), 2)
10284
options(rdfp.network_code = rdfp_options$network_code)
10385
})
10486

10587
test_that("dfp_performCustomTargetingKeyAction", {
106-
10788
options(rdfp.network_code = rdfp_options$test_network_code)
10889
request_data <- list(customTargetingKeyAction='DeleteCustomTargetingKeys',
10990
filterStatement=list('query'=paste0("WHERE name like 'Test%'")))
11091
dfp_performCustomTargetingKeyAction_result <- dfp_performCustomTargetingKeyAction(request_data, as_df=FALSE)
111-
11292
expect_is(dfp_performCustomTargetingKeyAction_result, "list")
113-
expect_length(dfp_performCustomTargetingKeyAction_result, 1)
114-
expect_named(dfp_performCustomTargetingKeyAction_result[[1]], c("numChanges"))
93+
expect_named(dfp_performCustomTargetingKeyAction_result, "numChanges")
94+
expect_equal(as.integer(dfp_performCustomTargetingKeyAction_result$numChanges), 1)
11595
options(rdfp.network_code = rdfp_options$network_code)
11696
})

tests/testthat/test-ForecastService.R

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ hypothetical_line_item <- list(lineItem=
2323
lineItemType=line_item_detail$lineItemType,
2424
costType=line_item_detail$costType,
2525
primaryGoal=line_item_detail$primaryGoal,
26-
targeting=line_item_detail$targeting
27-
)
28-
)
26+
targeting=line_item_detail$targeting))
2927

3028
test_that("dfp_getAvailabilityForecast", {
3129

@@ -52,30 +50,24 @@ test_that("dfp_getAvailabilityForecastById", {
5250
})
5351

5452
test_that("dfp_getDeliveryForecast", {
55-
5653
request_data <- list(lineItems=hypothetical_line_item,
5754
forecastOptions=list(ignoredLineItemIds=NULL))
5855
dfp_getDeliveryForecast_result <- dfp_getDeliveryForecast(request_data)
59-
6056
expect_is(dfp_getDeliveryForecast_result, "data.frame")
61-
expect_true(all(paste0("lineItemDeliveryForecasts.",
62-
c("lineItemId", "orderId", "unitType",
63-
"predictedDeliveryUnits", "deliveredUnits",
64-
"matchedUnits")) %in%
65-
names(dfp_getDeliveryForecast_result)))
57+
expect_equal(nrow(dfp_getDeliveryForecast_result), 1)
58+
expect_true(all(c("lineItemId", "orderId", "unitType",
59+
"predictedDeliveryUnits", "deliveredUnits", "matchedUnits") %in%
60+
names(dfp_getDeliveryForecast_result$lineItemDeliveryForecasts[[1]])))
6661
})
6762

6863
test_that("dfp_getDeliveryForecastByIds", {
69-
7064
# not specifying forecastOptions brings up NotNullError.ARG2_NULL, so send, but keep null
7165
request_data <- list(lineItemIds=line_item_detail$id,
7266
forecastOptions=list(ignoredLineItemIds=NULL))
7367
dfp_getDeliveryForecastByIds_result <- dfp_getDeliveryForecastByIds(request_data)
74-
7568
expect_is(dfp_getDeliveryForecastByIds_result, "data.frame")
76-
expect_true(all(paste0("lineItemDeliveryForecasts.",
77-
c("lineItemId", "orderId", "unitType",
78-
"predictedDeliveryUnits", "deliveredUnits",
79-
"matchedUnits")) %in%
80-
names(dfp_getDeliveryForecastByIds_result)))
69+
expect_equal(nrow(dfp_getDeliveryForecastByIds_result), 1)
70+
expect_true(all(c("lineItemId", "orderId", "unitType",
71+
"predictedDeliveryUnits", "deliveredUnits", "matchedUnits") %in%
72+
names(dfp_getDeliveryForecastByIds_result$lineItemDeliveryForecasts[[1]])))
8173
})

tests/testthat/test-LabelService.R

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,26 @@ dfp_createLabels_result <- dfp_createLabels(request_data)
3737
options(rdfp.network_code = rdfp_options$network_code)
3838

3939
test_that("dfp_createLabels", {
40-
4140
expect_is(dfp_createLabels_result, "data.frame")
4241
expect_true(all(c('id', 'name', 'description', 'types', 'isActive') %in% names(dfp_createLabels_result)))
4342
})
4443

4544
test_that("dfp_getLabelsByStatement", {
46-
4745
options(rdfp.network_code = rdfp_options$test_network_code)
4846
request_data <- list('filterStatement'=list('query'="WHERE name='Test'"))
49-
5047
dfp_getLabelsByStatement_result <- dfp_getLabelsByStatement(request_data)
5148
expect_is(dfp_getLabelsByStatement_result, "data.frame")
52-
5349
options(rdfp.network_code = rdfp_options$network_code)
5450
})
5551

5652
test_that("dfp_performLabelAction", {
57-
5853
options(rdfp.network_code = rdfp_options$test_network_code)
5954
request_data <- list(labelAction='DeactivateLabels',
6055
filterStatement=list('query'=paste0("WHERE id=", dfp_createLabels_result$id)))
61-
62-
dfp_performLabelAction_result <- dfp_performLabelAction(request_data, as_df=FALSE)
63-
expect_is(dfp_performLabelAction_result, "list")
64-
expect_length(dfp_performLabelAction_result, 1)
65-
expect_named(dfp_performLabelAction_result[[1]], c("numChanges"))
56+
dfp_performLabelAction_result <- dfp_performLabelAction(request_data)
57+
expect_is(dfp_performLabelAction_result, "data.frame")
58+
expect_true(all(c('numChanges') %in% names(dfp_performLabelAction_result)))
59+
expect_equal(as.integer(dfp_performLabelAction_result$numChanges), 1)
6660

6761
# check that action worked
6862
request_data <- list('filterStatement'=
@@ -71,27 +65,20 @@ test_that("dfp_performLabelAction", {
7165
dfp_getLabelsByStatement_result <- dfp_getLabelsByStatement(request_data)
7266
expect_is(dfp_getLabelsByStatement_result, "data.frame")
7367
expect_equal(nrow(dfp_getLabelsByStatement_result), 1)
74-
7568
options(rdfp.network_code = rdfp_options$network_code)
7669
})
7770

7871
test_that("dfp_updateLabels", {
79-
8072
options(rdfp.network_code = rdfp_options$test_network_code)
81-
8273
hypothetical_label_w_id <- list(id=dfp_createLabels_result$id,
8374
name=paste0(myuuid, '2'),
8475
description="Test2",
8576
types='COMPETITIVE_EXCLUSION')
8677
request_data <- list('labels'=hypothetical_label_w_id)
87-
8878
dfp_updateLabels_result <- dfp_updateLabels(request_data)
89-
9079
expect_is(dfp_updateLabels_result, "data.frame")
9180
expect_true(all(c('id', 'name', 'description', 'types', 'isActive') %in%
9281
names(dfp_updateLabels_result)))
9382
expect_equal(dfp_updateLabels_result$name, paste0(myuuid, '2'))
94-
9583
options(rdfp.network_code = rdfp_options$network_code)
9684
})
97-

tests/testthat/test-OrderService.R

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,20 @@ dfp_createOrders_result <- dfp_createOrders(request_data)
3333
options(rdfp.network_code = rdfp_options$network_code)
3434

3535
test_that("dfp_createOrders", {
36-
3736
expect_is(dfp_createOrders_result, 'data.frame')
3837
expect_true(all(c('id', 'name', 'notes', 'advertiserId',
3938
'traffickerId', 'isProgrammatic') %in% names(dfp_createOrders_result)))
40-
4139
})
4240

4341
test_that("dfp_getOrdersByStatement", {
44-
4542
options(rdfp.network_code = rdfp_options$test_network_code)
4643
request_data <- list('filterStatement'=list('query'="WHERE name LIKE 'Test%'"))
47-
4844
dfp_getOrdersByStatement_result <- dfp_getOrdersByStatement(request_data)
49-
5045
expect_is(dfp_getOrdersByStatement_result, "data.frame")
5146
options(rdfp.network_code = rdfp_options$network_code)
52-
5347
})
5448

5549
test_that("dfp_updateOrders", {
56-
5750
options(rdfp.network_code = rdfp_options$test_network_code)
5851
request_data <- list(list(id=dfp_createOrders_result$id,
5952
name=paste0('TestOrder2'),
@@ -77,21 +70,17 @@ test_that("dfp_updateOrders", {
7770
expect_is(dfp_updateOrders_result, 'data.frame')
7871
expect_true(all(c('id', 'name', 'notes', 'advertiserId',
7972
'traffickerId', 'isProgrammatic') %in% names(dfp_updateOrders_result)))
80-
8173
options(rdfp.network_code = rdfp_options$network_code)
82-
8374
})
8475

8576
test_that("dfp_performOrderAction", {
86-
8777
options(rdfp.network_code = rdfp_options$test_network_code)
8878
request_data <- list(orderAction='DeleteOrders',
8979
filterStatement=list('query'=paste0("WHERE name like 'Test%'")))
90-
91-
dfp_performOrderAction_result <- dfp_performOrderAction(request_data, as_df=FALSE)
92-
expect_is(dfp_performOrderAction_result, "list")
93-
expect_length(dfp_performOrderAction_result, 1)
94-
expect_named(dfp_performOrderAction_result[[1]], c("numChanges"))
80+
dfp_performOrderAction_result <- dfp_performOrderAction(request_data)
81+
expect_is(dfp_performOrderAction_result, "data.frame")
82+
expect_true(all(c('numChanges') %in% names(dfp_performOrderAction_result)))
83+
expect_equal(as.integer(dfp_performOrderAction_result$numChanges), 1)
9584

9685
# check that action worked
9786
request_data <- list('filterStatement'=
@@ -100,7 +89,6 @@ test_that("dfp_performOrderAction", {
10089
dfp_getLabelsByStatement_result <- dfp_getLabelsByStatement(request_data)
10190
expect_is(dfp_getLabelsByStatement_result, "data.frame")
10291
expect_equal(nrow(dfp_getLabelsByStatement_result), 0)
103-
10492
options(rdfp.network_code = rdfp_options$network_code)
10593
})
10694

tests/testthat/test-UserTeamAssociationService.R

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ options(rdfp.client_secret = rdfp_options$client_secret)
1010
dfp_auth(token = "rdfp_token.rds")
1111

1212
test_that("dfp_createUserTeamAssociations", {
13-
1413
request_data <- list(userteamassociations=list(teamId=239587,
1514
userId=149461448))
1615
options(rdfp.network_code = rdfp_options$test_network_code)
@@ -19,31 +18,24 @@ test_that("dfp_createUserTeamAssociations", {
1918
})
2019

2120
test_that("dfp_getUserTeamAssociationsByStatement", {
22-
2321
request_data <- list('filterStatement'=list('query'=paste0("WHERE userId='", dfp_getCurrentUser()$id, "'")))
24-
2522
dfp_getUserTeamAssociationsByStatement_result <- dfp_getUserTeamAssociationsByStatement(request_data)
26-
2723
expect_is(dfp_getUserTeamAssociationsByStatement_result, "data.frame")
2824
expect_true(all(c('teamId', 'defaultTeamAccessType', 'userId') %in% names(dfp_getUserTeamAssociationsByStatement_result)))
29-
3025
})
3126

3227
test_that("dfp_performUserTeamAssociationAction", {
33-
3428
options(rdfp.network_code = rdfp_options$test_network_code)
3529
request_data <- list(userTeamAssociationAction='DeleteUserTeamAssociations',
3630
statement=list('query'=paste0("WHERE name like 'Test%'")))
37-
38-
dfp_performUserTeamAssociationAction_result <- dfp_performUserTeamAssociationAction(request_data, as_df=FALSE)
39-
expect_is(dfp_performUserTeamAssociationAction_result, "list")
40-
expect_length(dfp_performUserTeamAssociationAction_result, 1)
41-
expect_named(dfp_performUserTeamAssociationAction_result[[1]], c("numChanges"))
31+
dfp_performUserTeamAssociationAction_result <- dfp_performUserTeamAssociationAction(request_data)
32+
expect_is(dfp_performUserTeamAssociationAction_result, "data.frame")
33+
expect_true(all(c('numChanges') %in% names(dfp_performUserTeamAssociationAction_result)))
34+
expect_equal(as.integer(dfp_performUserTeamAssociationAction_result$numChanges), 1)
4235
options(rdfp.network_code = rdfp_options$network_code)
4336
})
4437

4538
test_that("dfp_updateUserTeamAssociations", {
46-
4739
request_data <- list(userTeamAssociations=list(teamId=239587,
4840
userId=149461448))
4941
options(rdfp.network_code = rdfp_options$test_network_code)

0 commit comments

Comments
 (0)