-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildings_bulk_load_comparisons_complex.pg
167 lines (144 loc) · 5.68 KB
/
buildings_bulk_load_comparisons_complex.pg
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
------------------------------------------------------------------------------
-- Provide testing for buildings_bulk_load comparisons functions
-- with complex real world and Hausdorff Distance examples using pgTAP
------------------------------------------------------------------------------
-- Turn off echo.
\set QUIET 1
-- Format the output nicely.
\pset format unaligned
\pset tuples_only true
\pset pager
-- Revert all changes on failure.
\set ON_ERROR_ROLLBACK 1
\set ON_ERROR_STOP true
BEGIN;
SELECT plan(10);
--1----------------------------------------------------------
-- Test find_added function on complex data
SELECT results_eq(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.find_added(4) ORDER BY bulk_load_outline_id',
$$VALUES (2038), (2051), (2052), (2058),
(2059), (2060), (2061), (2062),
(2065), (2066), (2068), (2070),
(2076), (2077), (2079)$$,
'Check return of buildings bulk load find_added function'
);
--2----------------------------------------------------------
-- Test find_removed function on complex data
SELECT results_eq(
'SELECT building_outline_id FROM buildings_bulk_load.find_removed(4) ORDER BY building_outline_id',
$$VALUES (1042), (1058), (1064)$$,
'Check return of buildings bulk load find_removed function'
);
--3----------------------------------------------------------
-- Test find_matched function on complex data
SELECT results_eq(
'SELECT building_outline_id, bulk_load_outline_id FROM buildings_bulk_load.find_matched(4) ORDER BY building_outline_id, bulk_load_outline_id',
$$VALUES (1041, 2047), (1048, 2045),
(1056, 2042), (1060, 2050),
(1061, 2053), (1063, 2064),
(1065, 2075), (1066, 2073),
(1069, 2063), (1070, 2057),
(1071, 2072), (1072, 2074),
(1073, 2078), (1074, 2069),
(1075, 2071), (1076, 2080),
(1077, 2081), (1078, 2082),
(1082, 2085)$$,
'Check return of buildings_bulk_load find_matched function'
);
--4----------------------------------------------------------
-- Test find_related in complex data
SELECT results_eq(
'SELECT building_outline_id, bulk_load_outline_id FROM buildings_bulk_load.find_related(4) ORDER BY building_outline_id, bulk_load_outline_id',
$$VALUES (1038, 2048), (1039, 2046),
(1040, 2048), (1043, 2046),
(1044, 2043), (1045, 2046),
(1046, 2043), (1047, 2043),
(1049, 2043), (1050, 2043),
(1051, 2043), (1052, 2043),
(1053, 2044), (1054, 2044),
(1055, 2044), (1057, 2055),
(1059, 2049), (1059, 2054),
(1059, 2055), (1059, 2056),
(1062, 2037), (1062, 2039),
(1062, 2040), (1062, 2041),
(1067, 2067), (1068, 2067),
(1079, 2083), (1080, 2083),
(1083, 2086), (1083, 2087),
(1083, 2088)$$,
'Check return of buildings_bulk_load find related function'
);
--5----------------------------------------------------------
-- Test comparisons function inputs complex added outlines
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.added',
$$VALUES (2038), (2051), (2052), (2084)$$,
'Check added outlines after comparisons function has run'
);
--6----------------------------------------------------------
-- Test comparisons function inputs complex removed outlines
SELECT set_has(
'SELECT building_outline_id, qa_status_id, supplied_dataset_id, removed_id FROM buildings_bulk_load.removed',
$$VALUES (1042, 1, 4, 4),
(1058, 1, 4, 5),
(1081, 1, 4, 7)$$,
'Check removed outlines after comparisons function has run'
);
--7----------------------------------------------------------
-- Test comparisons function inputs complex matched outlines
-- by building_outline_id
SELECT set_has(
'SELECT building_outline_id FROM buildings_bulk_load.matched',
$$VALUES (1061), (1060),
(1041), (1048),
(1056)$$,
'Check building_outline_id of matched table after comparisons function has run'
);
--8----------------------------------------------------------
-- Test comparsisons function inputs complex related outlines
-- by bulk_load_outline id
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.matched',
$$VALUES (2053), (2050),
(2047), (2045),
(2042)$$,
'Check bulk_load_outline_ids of matched table after comparisons function has run'
);
--9----------------------------------------------------------
-- Test comparisons function inputs complex related outlines
-- by building_outline_id
SELECT set_has(
'SELECT building_outline_id FROM buildings_bulk_load.related',
$$VALUES (1059), (1057),
(1059), (1059),
(1059), (1038),
(1040), (1039),
(1043), (1045),
(1053), (1054),
(1055), (1044),
(1046), (1047),
(1049), (1050),
(1051), (1052),
(1062), (1062),
(1062), (1062)$$,
'Check building_outline_id of related table after comparisons function has run'
);
--10----------------------------------------------------------
-- Test comparisons function inputs complex related outlines
-- by bulk_load_outline_id
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.related',
$$VALUES (2056), (2055),
(2055), (2054),
(2049), (2048),
(2048), (2046),
(2046), (2046),
(2044), (2044),
(2044), (2043),
(2043), (2043),
(2043), (2043),
(2043), (2043),
(2041), (2040),
(2039), (2037)$$,
'Check bulk_load_outline_id of related table after comparisons function has run'
);