def setUp(self): """Set up test fixtures, if any.""" # This is a testing key, and keys are free. # Also, the API is rate-limited, so there's very little reason to abuse this. self.api_key = '2iG9VxVZJYGKRagpaqdxzhiCdgYbbtlkpfYXdUfa' self.eir = openei_rates.OpenEIRates(self.api_key) self.rate = self.eir.get_rate_by_url( 'https://openei.org/apps/IURDB/rate/view/5c488ad2b718b378f4caf7ea#1__Basic_Information' )
def test_good_label_query(self): """Test a valid query """ ei_rates = openei_rates.OpenEIRates(self.api_key) rate = ei_rates.get_rate_by_label(u'5c488ad2b718b378f4caf7ea') assert rate.label == u'5c488ad2b718b378f4caf7ea' assert rate.sector == 'Residential' assert rate.name == 'Residential TOD (Option A)' assert rate.utility == 'Sacramento Municipal Utility District' logger.info(rate)
def test_get_rate_by_url(self): """Looking to see if we can grab the rate from the URL """ ei_rates = openei_rates.OpenEIRates(self.api_key) rate = ei_rates.get_rate_by_label(u'5c488ad2b718b378f4caf7ea') url_rate = ei_rates.get_rate_by_url('https://openei.org/apps/IURDB/rate/view/5c488ad2b718b378f4caf7ea#1__Basic_Information') assert url_rate.label == u'5c488ad2b718b378f4caf7ea' assert url_rate.sector == 'Residential' assert url_rate.name == 'Residential TOD (Option A)' assert url_rate.utility == 'Sacramento Municipal Utility District' assert url_rate.label == rate.label logger.info(url_rate)
def test_bad_label_query(self): """Tests a bad query for a rate """ ei_rates = openei_rates.OpenEIRates(self.api_key) assert ei_rates.get_rate_by_label('thisisnotareal_label') is None
def test_class_construction(self): """Test whether the OpenEIRates class can be constructed.""" ei_rates = openei_rates.OpenEIRates(self.api_key) assert ei_rates.api.api_key == self.api_key