Permalink
Browse files

Fancy comments; extreme abstraction completed

  • Loading branch information...
1 parent 9ff066c commit 8a1730da3ae1d7fdb1e9b3702704730726d3015c quadrismegistus committed Apr 17, 2011
Showing with 52 additions and 7 deletions.
  1. +45 −0 FRNConversionsAPI.py
  2. +7 −7 tests/testcases.py
View
@@ -0,0 +1,45 @@
+from generic_api import *
+import urllib,json
+
+
+# Simple Python wrapper around the Broadband API provided by the FCC.
+
+class FRNConversionsAPI(GenericAPI):
+ """
+ FRNConversionsAPI:
+ - an API to access information about broadband provides.
+ - original API: http://reboot.fcc.gov/developer/frn-conversions-api
+
+ - methods:
+ -- getList(stateCode, multi)
+ takes stateCode=IL or stateCode=17 (FIPS code),
+ (optional) multi=Yes or multi=No to signify whether to include FRNs also operating outside this state.
+
+ -- getInfo(frn)
+ takes frn='0017855545' (FRN id)
+ """
+
+
+ def __init__(self):
+ apis= [
+ ('getList', 'http://data.fcc.gov/api/frn/getList'),
+ ('getInfo', 'http://data.fcc.gov/api/frn/getInfo')]
+
+ GenericAPI.__init__(self,apis)
+
+
+if __name__ == "__main__":
+ bb = FRNConversionsAPI()
+
+ x=bb.getList(stateCode='IL')
+ print type(x)
+ print len(x)
+ print x.keys()
+
+ #print x
+
+ print
+ x=bb.getInfo(frn='0017855545')
+ print type(x)
+ print len(x)
+ print x
View
@@ -4,13 +4,13 @@
sys.path.append('../')
from broadband_api import *
-from frn_api import *
+from FRNConversionsAPI import *
from block_conversion_api import *
class TestBroadbandAPI (unittest.TestCase):
def setUp(self):
self.bb = BroadbandApi()
- self.frnapi = FrnApi()
+ self.frnapi = FRNConversionsAPI()
#Sweep across the US and compare to precomputed values.
@@ -51,19 +51,19 @@ def test_Nowhere(self):
self.assertTrue(result['status'] == 'Fail')
def test_FRN(self):
- result = self.frnapi.request(frn='0017855545')
+ result = self.frnapi.getInfo(frn='0017855545')
self.assertTrue(result['Info']['frn'] == '0017855545')
def test_companyName(self):
- result = self.frnapi.request(frn='0017855545')
+ result = self.frnapi.getInfo(frn='0017855545')
self.assertTrue(result['Info']['companyName']=='Cygnus Telecommunications Corporation')
def test_FRNapiIsDict(self):
- result1 = self.frnapi.request(stateCode='IL')
- result2 = self.frnapi.request(frn='0017855545')
+ result1 = self.frnapi.getList(stateCode='IL')
+ result2 = self.frnapi.getInfo(frn='0017855545')
self.assertTrue(type(result1)==type({}) and type(result2)==type({}))
def test_CygnusInIL(self):
- result = self.frnapi.request(stateCode='IL')
+ result = self.frnapi.getList(stateCode='IL')
#print result['Frns']
#Cygnus Telecommunications Corporation
self.assertTrue('Cygnus Telecommunications Corporation' in [x['companyName'] for x in result['Frns']['Frn']])

0 comments on commit 8a1730d

Please sign in to comment.