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 pathapproval_test.go
191 lines (180 loc) · 4.8 KB
/
approval_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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package opendsd_test
import (
"bytes"
"fmt"
"log"
"net/http"
"net/http/httptest"
"testing"
"github.com/scoutred/opendsd"
)
var approvalTestData = `
{
"Header": [{
"Jurisdiction": "City of San Diego",
"Agency": "Development Services Department",
"AgencyAddress": "1222 First Ave, San Diego, CA 92101",
"AgencyWebsite": "www.sandiego.gov",
"ExtractSystem": "Extract System",
"ExtractDate": "10/30/2016 6:00:28 PM",
"ExtractQuery": "Project Status XML"
}],
"ApprovalId": 1117208,
"Project": {
"Customers": null,
"ReviewCycles": null,
"Jobs": null,
"Fees": null,
"Invoices": null,
"ProjectId": 319781,
"Title": "Kaiser SD PI/Grading/Ded",
"Scope": "KEARNY MESA Grading and public improvement, and public right of way dedication and Street Name for the new Kaiser Hospital. ",
"ApplicationExpiration": "2014-04-11T17:00:00",
"ApplicationExpired": true,
"AdminHold": false,
"DevelopmentId": 176644,
"DevelopmentTitle": "Kaiser Hospital",
"ApplicationDate": "2013-04-11T17:00:00",
"AccountNum": "24003691",
"JobOrderNum": null,
"Header": null,
"ProjectManagerId": 3329,
"ProjectManager": {
"ProjectManagerId": 3329,
"Name": "Lynch, Pete",
"PhoneNum": "",
"EmailAddress": "[email protected]",
"ActiveIndicator": true
}
},
"Job": {
"SignOffs": [],
"ApprovalInfo": [],
"Approvals": [],
"ProjectId": 319781,
"JobId": 635029,
"Description": "37444-B Street Dedication on por lot 1of map 4674 ",
"APN": "369-121-14-00",
"StreetAddress": "5201 RUFFIN RD ",
"MapReference": "XXXX-XX",
"SortableStreetAddress": "RUFFIN RD 0000005201 ",
"Latitude": 32.830113,
"Longitude": -117.126156,
"NAD83Northing": null,
"NAD83Easting": null,
"JobFeesSubTotal": null
},
"BCCodes": [{
"JobId": 833119,
"BCCodeId": 103,
"BCCode": "Three or Four Family Apt"
}],
"Approval": {
"JobId": 635029,
"ApprovalId": 1117208,
"Type": "Public Right of Way Dedication",
"Status": "Issued",
"Scope": "Street dedication over portion of lot 1 of map 4674. Recorded April 4, 2014. Document No. 2014-0133239 and Document No. 2014-0133247.",
"Depiction": "2",
"IssuedBy": "Lynch, Pete",
"IssueDate": "2016-10-20T15:39:58",
"FirstInspectionDate": null,
"CompleteCancelDate": null,
"PermitHolder": "Steven Doshay",
"NetChangeDU": "",
"Valuation": "",
"SquareFootage": null
},
"Inspections": [{
"ApprovalId": 1501285,
"InspectionId": 2682138,
"InspectionTier": "2",
"InspectionType": "Final(2)",
"InspectionDiscipline": "Mechanical",
"InspectionStatus": "Available",
"InspectionStatusSeq": "20",
"InspectorId": null,
"InspectorName": "",
"InspectorPhone": "",
"InspectorActive": "",
"SchedulingInstruction": "Call (858) 581-7111 to schedule this inspection",
"CustRequestable": "Y",
"ScheduledDt": null,
"PerformedDt": null,
"InspectionResult": "",
"InspectorEmail": "",
"InspectionDetails": []
}],
"InspectionIssues": [{
"InspectionIssueId": 196533,
"ApprovalId": 1501283,
"InspectionTier": "3",
"Issue": "4,000 psi Concrete dtl E/S8",
"Class": "Special Inspection: Concrete",
"Visibility": "Regular",
"CreatedBy": "Anderson, John",
"CreatedDt": "2015-07-26T13:17:40",
"ClearedBy": "",
"ClearedDt": null,
"ClearedNote": ""
}],
"ApprovalFees": [{
"FeeTypeId": 3785,
"ProjectId": 401996,
"FeeType": "Recordation Fee-County",
"FeeCategory": "Inspection Fees",
"FeeTypeUnit": "Pages",
"FeeQuantityRequired": "3",
"FeeQuantityPaid": "3",
"InvoiceId": 729995,
"InvoiceStatus": "Paid on "
}],
"Exceptions": [{
"ApprovalId": 1472397,
"ApprovalStatusSeq": null,
"Exception": "Inspection: You have 8 inspections remaining in the plan.",
"ApprovalStatus": ""
}],
"DependentPackages": [],
"DependantApprovals": [{
"ApprovalId": 1501283,
"InspectionTier": "3",
"DepApprApprovalId": 1550442,
"DepApprType": "Right Of Way Permit-Const Plan",
"DepApprStatus": "Created",
"StatusReq": "Completed",
"RequirementMet": "N",
"AddedBy": "Fridman, Bella",
"AddedDt": "2016-04-21T14:21:20"
}]
}`
func TestDecodApproval(t *testing.T) {
var err error
buf := bytes.NewBufferString(approvalTestData)
approval, err := opendsd.DecodeApproval(buf)
if err != nil {
t.Errorf("error parsing: %v", err)
}
log.Printf("approval %+v", approval)
}
func TestApprovalByID(t *testing.T) {
// setup test muxer
mux := http.NewServeMux()
// register our test route
mux.HandleFunc("/approval/1117208",
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, approvalTestData)
},
)
// setup test server
server := httptest.NewServer(mux)
// setup test client
client := opendsd.NewClient()
// use the generated testing url
client.APIRoot = server.URL
approval, err := client.ApprovalByID(1117208)
if err != nil {
t.Errorf("ApprovalByID error: %v", err)
}
log.Printf("approval %+v", approval)
}