-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtest_mosaic.R
More file actions
131 lines (113 loc) · 4.73 KB
/
Copy pathtest_mosaic.R
File metadata and controls
131 lines (113 loc) · 4.73 KB
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
test_that("mosaic dataset level annotations work", {
annotation <- mosaic_annotate_dataset("PS122/2")
example_annotation <- list(
#Basis
list(
propertyURI = list(label = "hasBasis",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000034"),
valueURI = list(label = "Polarstern",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000030")
),
#Project
list(
propertyURI = list(label = "hasProjectLabel",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000025"),
valueURI = list(label = "MOSAiC20192020",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000023")
),
#Campaign
list(
propertyURI = list(label = "isPartOfCampaign",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000032"),
valueURI = list(label = "PS122/2",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000018")
)
)
expect_equal(
eml_get_simple(example_annotation, "label"),
eml_get_simple(annotation, "label")
)
expect_equal(
eml_get_simple(example_annotation, "propertyURI"),
eml_get_simple(annotation, "propertyURI")
)
})
test_that("multiple campaigns work", {
annotations <- mosaic_annotate_dataset(c("PS122/2", "PS122/1"))
expect_equal(length(annotations), 4)
})
test_that("multiple campaigns with different basis work", {
annotations <- mosaic_annotate_dataset(c("PS122/2", "AF-MOSAiC-1"))
example_annotation <- list(
list(
propertyURI = list(label = "hasBasis",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000034"),
valueURI = list(label = "Akademik Fedorov",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000038")
),
#Basis
list(
propertyURI = list(label = "hasBasis",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000034"),
valueURI = list(label = "Polarstern",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000030")
),
#Project
list(
propertyURI = list(label = "hasProjectLabel",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000025"),
valueURI = list(label = "MOSAiC20192020",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000023")
),
#Campaign
list(
propertyURI = list(label = "isPartOfCampaign",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000032"),
valueURI = list(label = "AF-MOSAiC-1",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000020")
),
list(
propertyURI = list(label = "isPartOfCampaign",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00000032"),
valueURI = list(label = "PS122/2",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00000018")
)
)
expect_equal(length(annotations), 5)
expect_equal(
eml_get_simple(example_annotation, "label"),
eml_get_simple(annotations, "label")
)
expect_equal(
eml_get_simple(example_annotation, "propertyURI"),
eml_get_simple(annotations, "propertyURI")
)
})
test_that("mosaic attribute level annotations work", {
annotation <- mosaic_annotate_attribute("PS122/2_14-270")
example_annotation <- list(
#event
list(
propertyURI = list(label = "wasGeneratedBy",
propertyURI = "http://www.w3.org/ns/prov#wasGeneratedBy"),
valueURI = list(label = "PS122/2_14-270",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00004550")
),
#Method/Device
list(
propertyURI = list(label = "deployedSystem",
propertyURI = "https://purl.dataone.org/odo/MOSAIC_00002201"),
valueURI = list(label = "Ultra-Wideband Software-defined Microwave Radiometer (0.5-2GHZ)",
valueURI = "https://purl.dataone.org/odo/MOSAIC_00001163")
)
)
expect_equal(
eml_get_simple(example_annotation, "propertyURI"),
eml_get_simple(annotation, "propertyURI")
)
})
test_that("the MOSAiC portal filter works", {
basis <-
"<choice><label>Akademik Fedorov</label><value>https://purl.dataone.org/odo/MOSAIC_00000038</value></choice><choice><label>Akademik Tryoshnikov</label><value>https://purl.dataone.org/odo/MOSAIC_00011203</value></choice><choice><label>Polar 5</label><value>https://purl.dataone.org/odo/MOSAIC_00011224</value></choice><choice><label>Polar 6</label><value>https://purl.dataone.org/odo/MOSAIC_00011223</value></choice><choice><label>Polarstern</label><value>https://purl.dataone.org/odo/MOSAIC_00000030</value></choice>"
expect_equal(mosaic_portal_filter("Basis"), basis)
})