def get_district_and_muni(url, entity_list): """ This is the district and muni finder main() . it searchs a url from the open-muni API for all results and finds all Gis data it can find using these results. :param url: the url which is the lookup for all muni's in the open-muni API :param entity_list: the entity_list this is mostly here because of the recursive behivior of the function. :return: returns a entity dictionary which has all entity's found and all which aren't. """ print url data = tools.get_data_as_dict(url) next_page = '' if data['next']: next_page = data['next'] results_list = data['results'] for result in results_list: if not result['name_en']: #TODO add support for results with no english keyword continue # if their is no name in english. i can't store the files for now so continue. entity = objects.entity(result) if get_entity_polygon(entity): entity_list['found'].append(entity) # if found add to the entity list else: entity_list['not_found'].append(entity) if next_page: get_district_and_muni(next_page, entity_list) return entity_list
def test_dnrEntity(self): answer = \ """{ "handle" : "XXXX", "entityNames": [ "Joe Bob, Inc.", "Bobby Joe Shopping" ], "status" : [ "validated", "locked" ], "postalAddress" : [ "123 Maple Ave", "Suite 90001", "Vancouver", "BC", "12393" ], "emails" : [ "*****@*****.**", "*****@*****.**" ], "phones" : { "office" : [ "1-958-555-4321", "1-958-555-4322" ], "fax" : [ "1-958-555-4323" ], "mobile" : [ "1-958-555-4324" ] }, "remarks" : [ "she sells seas shells", "down by the seashore" ], "links" : [ { "value" : "http://example.com/entity/XXXX", "rel" : "self", "href" : "http://example.com/entity/XXXX" } ], "port43" : "whois.example.net", "registrationDate" : "1990-12-31T23:59:60Z", "registrationBy" : "ABC123", "lastChangedDate" : "1990-12-31T23:59:60Z", "lastChangedBy" : "ABC123", "sponsoredBy" : "SponsorXYZ", "resoldBy" : "ResellerPDQ" }""" reslt = objects.entity( # roles 'XXXX', ['Joe Bob, Inc.', 'Bobby Joe Shopping'], ['validated', 'locked'], None, ['123 Maple Ave', 'Suite 90001', 'Vancouver', 'BC', '12393'], ['*****@*****.**', '*****@*****.**'], {'office': ['1-958-555-4321', '1-958-555-4322'], 'fax': ['1-958-555-4323'], 'mobile': ['1-958-555-4324']}, ['she sells seas shells', 'down by the seashore'], {'value': 'http://example.com/entity/XXXX', 'rel': 'self', 'href': 'http://example.com/entity/XXXX'}, port43='whois.example.net', registrationDate='1990-12-31T23:59:60Z', registrationBy='ABC123', lastChangedDate='1990-12-31T23:59:60Z', lastChangedBy='ABC123', sponsoredBy='SponsorXYZ', resoldBy='ResellerPDQ', ) self.assertJSON(reslt, answer)
def test_rirDomain(self): answer = \ """{ "handle" : "XXXX", "name" : "192.in-addr.arpa", "nameServers" : [ { "name" : "ns1.rir.net" }, { "name" : "ns2.rir.net" } ], "delegationKeys" : [ { "algorithm": 7, "digest" : "E68C017BD813B9AE2F4DD28E61AD014F859ED44C", "digestType" : 1, "keyTag" : 53814 }], "remarks" : [ "she sells seas shells", "down by the seashore" ], "links" : [ { "value": "http://example.net/domain/XXXX", "rel" : "self", "href" : "http://example.net/domain/XXXX" } ], "registrationDate" : "1990-12-31T23:59:60Z", "lastChangedDate" : "1990-12-31T23:59:60Z", "lastChangedBy" : "*****@*****.**", "entities" : [ { "handle" : "XXXX", "entityNames": [ "Joe Bob, Inc.", "Bobby Joe Shopping" ], "roles" : [ "registrant" ], "postalAddress" : ["123 Maple Ave", "Suite 90001", "Vancouver", "BC", "12393" ], "emails" : [ "*****@*****.**", "*****@*****.**" ], "phones" : { "office" : [ "1-958-555-4321", "1-958-555-4322" ], "fax" : [ "1-958-555-4323" ], "mobile" : [ "1-958-555-4324" ] }, "remarks" : [ "she sells seas shells", "down by the seashore" ], "links" : [ { "value": "http://example.net/entity/xxxx", "rel" : "self", "href" : "http://example.net/entity/xxxx" } ], "registrationDate" : "1990-12-31T23:59:60Z", "lastChangedDate" : "1990-12-31T23:59:60Z", "lastChangedBy" : "*****@*****.**" } ] } """ reslt = objects.domain('XXXX', '192.in-addr.arpa', None, None, [objects.nameserver(None, 'ns1.rir.net'), objects.nameserver(None, 'ns2.rir.net')], objects.entity('XXXX', ['Joe Bob, Inc.', 'Bobby Joe Shopping'], None, 'registrant', ['123 Maple Ave', 'Suite 90001', 'Vancouver', 'BC', '12393'], ['*****@*****.**', '*****@*****.**'], {'office': ['1-958-555-4321', '1-958-555-4322'], 'fax': ['1-958-555-4323'], 'mobile': ['1-958-555-4324']}, ['she sells seas shells', 'down by the seashore'], objects.link("http://example.net/entity/xxxx", "self"), registrationDate= "1990-12-31T23:59:60Z", lastChangedDate= "1990-12-31T23:59:60Z", lastChangedBy= "*****@*****.**" ), objects.delegationKey(7, 'E68C017BD813B9AE2F4DD28E61AD014F859ED44C', 1, 53814), ['she sells seas shells', 'down by the seashore'], objects.link('http://example.net/domain/XXXX', 'self'), registrationDate='1990-12-31T23:59:60Z', lastChangedDate='1990-12-31T23:59:60Z', lastChangedBy='*****@*****.**') self.assertJSON(reslt, answer) ## TODO: more tests from RFC when one is published