This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcode_enforcement_case_test.go
143 lines (135 loc) · 5.19 KB
/
code_enforcement_case_test.go
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
package opendsd_test
import (
"bytes"
"encoding/xml"
"reflect"
"testing"
"time"
"github.com/scoutred/opendsd"
)
var codeEnforcementTestCaseData = `
<?xml version="1.0" encoding="UTF-8"?>
<extract_results>
<!--City of San Diego Development Services Department-->
<!--Please see dtd for extract explanation-->
<metadata>
<jurisdiction>City of San Diego</jurisdiction>
<agency>Development Services Department</agency>
<agency_address>1222 First AV, San Diego, CA 92101</agency_address>
<agency_website>http://www.sandiego.gov/development-services/</agency_website>
<data_extract>
<extract_system>PTSxml Report Id: 203</extract_system>
<query>VWXML_CECASES</query>
<extract_date>11/06/2016 22:35</extract_date>
<report_title>Code Enforcement Report</report_title>
<request_id/>
</data_extract>
</metadata>
<cases>
<case case_id="3351">
<case_source>Other City Department</case_source>
<description>GARAGE CONVERSN - [Addr: 2034 JULIAN AV APN: 538-330-28 Owner: CORDERO, MARIE/NORMA ] </description>
<open_date>1993-03-30</open_date>
<APN>5383302800</APN>
<street_address>2034 JULIAN AV </street_address>
<sortable_street_address>JULIAN AV 0000002034 </sortable_street_address>
<map_reference>XXXX-XX</map_reference>
<longitude>-117.140165</longitude>
<latitude>32.70176</latitude>
<nad83_northing>1836282</nad83_northing>
<nad83_easting>6287823</nad83_easting>
<workgroup>Zoning</workgroup>
<investigator_name>Vasquez, Edward</investigator_name>
<investigator_phone_number>(619)533-6275</investigator_phone_number>
<investigator_email_address>[email protected]</investigator_email_address>
<investigator_active>Y</investigator_active>
<last_action>City Attorney Referral - Referred</last_action>
<last_action_due_date>2015-06-06</last_action_due_date>
<remedy_msg>New plans submitted & approved with the CED Stamp for submittal to DSD Reveiw Section per VMN.</remedy_msg>
<complaints>
<complaint complaint_type_id="314">
<complaint_type>Zoning-Garage Conversion</complaint_type>
</complaint>
</complaints>
</case>
</cases>
</extract_results>`
func TestDecodCodeEnforcementCases(t *testing.T) {
testcases := []struct {
testdata string
expected opendsd.CodeEnforcementCases
}{
{
testdata: codeEnforcementTestCaseData,
expected: opendsd.CodeEnforcementCases{
Metadata: opendsd.Metadata{
Jurisdiction: "City of San Diego",
Agency: "Development Services Department",
AgencyAddress: "1222 First AV, San Diego, CA 92101",
AgencyWebsite: "http://www.sandiego.gov/development-services/",
DataExtract: opendsd.DataExtract{
ExtractSystem: "PTSxml Report Id: 203",
Query: "VWXML_CECASES",
ExtractDate: opendsd.ApplicationTimestamp(time.Date(2016, 11, 6, 22, 35, 0, 0, time.UTC)),
ReportTitle: "Code Enforcement Report",
},
},
Cases: []opendsd.CodeEnforcementCase{
{
XMLName: xml.Name{
Local: "case",
},
ID: "3351",
CaseSource: "Other City Department",
Description: "GARAGE CONVERSN - [Addr: 2034 JULIAN AV APN: 538-330-28 Owner: CORDERO, MARIE/NORMA ] ",
OpenDate: "1993-03-30",
CloseDate: "",
CloseReason: "",
CloseNote: "",
APN: "5383302800",
StreetAddress: "2034 JULIAN AV ",
SortableStreetAddress: "JULIAN AV 0000002034 ",
MapReference: "XXXX-XX",
Lat: 32.70176,
Lon: -117.140165,
NAD83Northing: "1836282",
NAD83Easting: "6287823",
Workgroup: "Zoning",
InvestigatorName: "Vasquez, Edward",
InvestigatorPhoneNumber: "(619)533-6275",
InvestigatorEmailAddress: "[email protected]",
InvestigatorActive: "Y",
LastAction: "City Attorney Referral - Referred",
LastActionDueDate: "2015-06-06",
RemedyMsg: "New plans submitted & approved with the CED Stamp for submittal to DSD Reveiw Section per VMN.",
Complaints: []opendsd.CodeEnforcementCaseComplaint{
{
XMLName: xml.Name{
Local: "complaint",
},
TypeID: "314",
Type: "Zoning-Garage Conversion",
},
},
},
},
},
},
}
for i, tc := range testcases {
buf := bytes.NewBufferString(tc.testdata)
output, err := opendsd.DecodeCodeEnforcementCases(buf)
if err != nil {
t.Errorf("testcase (%v) failed err: %v %v", i, err)
return
}
if !reflect.DeepEqual(output.Metadata, tc.expected.Metadata) {
t.Errorf("testcase (%v) failed. expected Metadata \n\n %+v \n\n does not match output Metadata \n\n %+v", i, tc.expected.Metadata, output.Metadata)
return
}
if !reflect.DeepEqual(output.Cases, tc.expected.Cases) {
t.Errorf("testcase (%v) failed. expected Cases \n\n %+v \n\n does not match output Cases \n\n %+v", i, tc.expected.Cases, output.Cases)
return
}
}
}