-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildings_bulk_load_comparison.pg
154 lines (126 loc) · 5.2 KB
/
buildings_bulk_load_comparison.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
------------------------------------------------------------------------------
-- Provide unit testing for buildings_bulk_load schema 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----------------------------------------------------------
-- New Buildings contents
SELECT results_eq(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.find_added(1) ORDER BY bulk_load_outline_id',
$$VALUES (2003),
(2010)$$,
'Check contents of new buildings table after building comparison function has run'
);
--2----------------------------------------------------------
-- Removed Buildings contents
SELECT results_eq(
'SELECT building_outline_id FROM buildings_bulk_load.find_removed(1) ORDER BY building_outline_id',
$$VALUES (1004),
(1006)$$,
'Check contents of removed buildings table after building comparison function has run'
);
--3----------------------------------------------------------
-- related
SELECT results_eq(
'SELECT building_outline_id, bulk_load_outline_id FROM buildings_bulk_load.find_related(1) ORDER BY building_outline_id, bulk_load_outline_id',
$$VALUES (1007, 2005), (1008, 2005),
(1009, 2006), (1010, 2006),
(1011, 2006), (1012, 2007),
(1013, 2007), (1014, 2007),
(1015, 2007), (1016, 2008),
(1017, 2008), (1018, 2008),
(1019, 2008), (1020, 2008),
(1021, 2009), (1022, 2009),
(1023, 2009), (1024, 2009),
(1025, 2009), (1026, 2009),
(1027, 2011), (1027, 2012),
(1028, 2013), (1028, 2014),
(1028, 2015), (1029, 2016),
(1029, 2017), (1029, 2018),
(1029, 2019), (1030, 2020),
(1030, 2021), (1030, 2022),
(1030, 2023), (1030, 2024),
(1031, 2025), (1031, 2026),
(1031, 2027), (1031, 2028),
(1031, 2029), (1031, 2030),
(1032, 2032), (1032, 2033),
(1033, 2033)$$,
'Check bulk load outlines of related table after buildings comparison function has run'
);
--4------------------------------------------------------
-- matched
SELECT results_eq(
'SELECT building_outline_id, bulk_load_outline_id FROM buildings_bulk_load.find_matched(1) ORDER BY building_outline_id',
$$VALUES (1001, 2031), (1002, 2001),
(1003, 2002), (1005, 2004)$$,
'Check outlines pairs of matched table after buildings comparison .find_matched function has run'
);
--5------------------------------------------------------
-- added
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.added',
$$VALUES (2003),
(2010)$$,
'Check contents of new buildings table after building comparison function has run'
);
--6------------------------------------------------------
-- removed
SELECT set_has(
'SELECT building_outline_id, qa_status_id, supplied_dataset_id, removed_id FROM buildings_bulk_load.removed',
$$VALUES (1004, 1, 1, 1),
(1006, 1, 1, 2)$$,
'Check contents of removed buildings table after building comparison function has run'
);
--7------------------------------------------------------
-- related bulk_load_outline
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.related building_outline_id',
$$VALUES (2005), (2006), (2007), (2008),
(2009), (2011), (2012), (2013),
(2014), (2015), (2016), (2017),
(2018), (2019), (2020), (2021),
(2022), (2023), (2024), (2025),
(2026), (2027), (2028), (2029),
(2030), (2032), (2033)$$,
'Check bulk load outlines of related table after buildings comparison function has run'
);
--8----------------------------------------------------
-- related building_outline
SELECT set_has(
'SELECT building_outline_id FROM buildings_bulk_load.related',
$$VALUES (1007), (1008), (1009), (1010),
(1011), (1012), (1013), (1014),
(1015), (1016), (1017), (1018),
(1019), (1020), (1021), (1022),
(1023), (1024), (1025), (1026),
(1027), (1028), (1029), (1031),
(1032), (1033)$$,
'Check current outlines of related table after buildings comparison function has run'
);
--9------------------------------------------------------
-- best_candidates bulk_load_outline_id
SELECT set_has(
'SELECT bulk_load_outline_id FROM buildings_bulk_load.matched',
$$VALUES (2001), (2002),
(2004), (2031)$$,
'Check supplied outlines of best candidates table after buildings comparison function has run'
);
--10------------------------------------------------------
-- best_candidates building_outline_id
SELECT set_has(
'SELECT building_outline_id FROM buildings_bulk_load.matched',
$$VALUES (1001), (1002),
(1003), (1005)$$,
'Check current outlines of best candidates table after buildings comparison function has run'
);
-- Finish pgTAP testing
SELECT * FROM finish();