def test_proportion_of_energy_submetered(self): meters = [] for i in [1,2,3]: meter_meta = self.datastore.load_metadata('building1')['elec_meters'][i] meter_id = ElecMeterID(i, 1, 'REDD') meter = ElecMeter(self.datastore, meter_meta, meter_id) meters.append(meter) mains = meters[0] mg = MeterGroup(meters) self.assertEqual(mg.proportion_of_energy_submetered(), 1.0) # Check a second time to check cache works self.assertEqual(mg.proportion_of_energy_submetered(), 1.0) mg.clear_cache()
def test_dual_supply(self): elec_meters = {1: {'data_location': '/building1/elec/meter1', 'device_model': 'Energy Meter'}, 2: {'data_location': '/building1/elec/meter1', 'device_model': 'Energy Meter'}, 3: {'data_location': '/building1/elec/meter1', 'device_model': 'Energy Meter'}} appliances = [{'type': 'washer dryer', 'instance': 1, 'meters': [1,2]}, {'type': 'fridge', 'instance': 1, 'meters': [3]}] mg = MeterGroup() mg.import_metadata(self.datastore, elec_meters, appliances, BuildingID(1, 'REDD')) self.assertEqual(mg['washer dryer'].total_energy()['active'], mg['fridge'].total_energy()['active'] * 2) # Test total_energy a second time to check cache works self.assertEqual(mg['washer dryer'].total_energy()['active'], mg['fridge'].total_energy()['active'] * 2) self.assertIsInstance(mg['washer dryer'], MeterGroup) self.assertIsInstance(mg['fridge'], ElecMeter) mg.clear_cache()