def test_populate_measures(self): # BuildingSync v1.0.0 has 222 enums self.assertEqual(Measure.objects.count(), 222) # if we run it again, it shouldn't add anything new Measure.populate_measures(self.org.id) self.assertEqual(Measure.objects.count(), 222)
def test_validate_measures(self): measures = [("renewable_energy_systems", "install_photovoltaic_system"), ("other_hvac", "add_or_repair_economizer"), ("chiller_plant_improvements", "clean_and_or_repair")] objs = [] for m in measures: objs.append(Measure.objects.get(category=m[0], name=m[1])) obj_ids = [m.id for m in objs] obj_names = ["{}.{}".format(m.category, m.name) for m in objs] results = Measure.validate_measures(obj_ids) self.assertEqual(obj_ids, results) results = Measure.validate_measures(obj_names) self.assertEqual(obj_ids, results) results = Measure.validate_measures(['.']) self.assertEqual([], results) extra_blank = list(obj_ids) extra_blank.append("") results = Measure.validate_measures(extra_blank) self.assertEqual(obj_ids, results) extra_malformed = list(obj_ids) extra_malformed.append("abcdef") results = Measure.validate_measures(extra_malformed) self.assertEqual(obj_ids, results) extra_missing = list(obj_ids) extra_missing.append("a.b") results = Measure.validate_measures(extra_missing) self.assertEqual(obj_ids, results) results = Measure.validate_measures([]) self.assertEqual(results, [])
def setUp(self): self.user = User.objects.create_superuser('*****@*****.**', '*****@*****.**', 'test_pass') self.org, _, _ = create_organization(self.user) Measure.populate_measures(self.org.id)
def test_populate_measures(self): self.assertEqual(Measure.objects.count(), 222) # if we run it again, it shouldn't add anything new Measure.populate_measures(self.org.id) self.assertEqual(Measure.objects.count(), 222)
def setUp(self): self.org = Organization.objects.create() Measure.populate_measures(self.org.id)