Skip to content

Commit

Permalink
Merge e42e7eb into c67b653
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang committed Aug 7, 2023
2 parents c67b653 + e42e7eb commit ea06572
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 9 deletions.
22 changes: 13 additions & 9 deletions uw_space/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ def search_by_number(self, facility_number):

def __process_json(self, json_data):
objs = []
facilitys = json_data.get("Facilitys")
for facility in facilitys:
status = facility.get("Status")
fnumber = facility.get("FacilityNumber")
if fnumber and len(fnumber):
fac = self.search_by_number(fnumber)
if fac:
fac.status = status
objs.append(fac)
if "Facilities" in json_data:
facilities = json_data.get("Facilities")
elif "Facilitys" in json_data:
facilities = json_data.get("Facilitys")
if facilities:
for facility in facilities:
status = facility.get("Status")
fnumber = facility.get("FacilityNumber")
if fnumber and len(fnumber):
fac = self.search_by_number(fnumber)
if fac:
fac.status = status
objs.append(fac)
return objs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"TotalCount": 1,
"Facilities": [
{
"FacilityCode": "MDR",
"FacilityType": {
"Code": "BLDG",
"Description": "Building"
},
"Status": "A",
"AggregateFacilityNumber": "6471",
"Site": "SEA_MN",
"Name": "Madrona Hall",
"LongName": "Madrona Hall",
"LeasedOrOwned": "OWNED",
"StreetAddress": "4320 Little Canoe Channel NE",
"City": "Seattle",
"State": "WA",
"PostalCode": "98195",
"Country": "UNITED STATES",
"CountryCode2": "US",
"CountryCode3": "USA",
"County": "King",
"RepositoryTimeStamp": "2023-08-01T07:04:51.322-07:00",
"FacilityURI": {
"FacilityNumber": "6471",
"FacilityCode": "MDR",
"Description": "Madrona Hall",
"Href": "/space/v2/facility/6471.json"
},
"FacilityNumber": "6471"
}
],
"Current": {
"Href": "/space/v2/facility.json?facility_type=&facility_code=MDR&status=&aggregate_number=&site=&name=&long_name=&leased_or_owned=&street=&city=&state=&postal_code=&changed_since_date=&page_start=1&page_size=10",
"FacilityType": null,
"FacilityCode": "MDR",
"Status": null,
"AggregateNumber": null,
"Site": null,
"Name": null,
"LongName": null,
"LeasedOrOwned": null,
"Street": null,
"City": null,
"State": null,
"PostalCode": null,
"PageStart": "1",
"PageSize": "10",
"ChangedSinceDate": null
},
"Next": null,
"Previous": null
}
52 changes: 52 additions & 0 deletions uw_space/resources/space/file/space/v2/facility/6471.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Addresses": [
{
"Code": "1",
"PrimaryAddress": "Y",
"StreetAddress": "4320 Little Canoe Channel NE",
"City": "Seattle",
"State": "WA",
"PostalCode": "98195",
"Country": "UNITED STATES",
"CountryCode2": "US",
"CountryCode3": "USA",
"County": "King"
},
{
"Code": "2",
"PrimaryAddress": "N",
"StreetAddress": "4322 Little Canoe Channel NE",
"City": "Seattle",
"State": "WA",
"PostalCode": "98195",
"Country": "UNITED STATES",
"CountryCode2": "US",
"CountryCode3": "USA",
"County": "King"
}
],
"AggregateFacilityNumber": "6471",
"FacilityType": {
"Code": "BLDG",
"Description": "Building"
},
"GrossSquareFeet": "141659",
"LeasedOrOwned": "OWNED",
"ModifiedDate": "9/22/2022 12:49:38 PM",
"Site": {
"Code": "SEA_MN",
"Description": "Seattle Main Campus"
},
"RepositoryTimeStamp": "2023-08-01T07:04:51.322-07:00",
"SpaceCount": 446,
"Status": "A",
"CenterPoint": {
"Latitude": 47.6601320001,
"Longitude": -122.305391,
"Href": "http://maps.google.com/maps?ll=47.6601320001,-122.305391"
},
"Name": "Madrona Hall",
"LongName": "Madrona Hall",
"FacilityCode": "MDR",
"FacilityNumber": "6471"
}
14 changes: 14 additions & 0 deletions uw_space/tests/test_facilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ def test_search_by_code(self):
Facilities().search_by_code, "None"
)

fac = Facilities().search_by_code("MDR")
self.assertEqual(len(fac), 1)
self.assertEqual(fac[0].json_data(), {
'code': 'MDR',
'last_updated': '2022-09-22 12:49:38',
'latitude': 47.6601320001,
'longitude': -122.305391,
'name': 'Madrona Hall',
'number': '6471',
'site': 'Seattle Main Campus',
'status': 'A',
'type': 'Building'
})

def test_search_by_number(self):
fac = Facilities().search_by_number("1347")
data['status'] = ''
Expand Down

0 comments on commit ea06572

Please sign in to comment.