def mer230_base_tags(): tt_dict = [ {'pos': 1, 'name': 'Ts_active',}, {'pos': 2, 'name': 'Ts_reactive',}, {'pos': 3, 'name': 'T1_active',}, {'pos': 4, 'name': 'T1_reactive',}, {'pos': 5, 'name': 'T2_active',}, {'pos': 6, 'name': 'T2_reactive',}, {'pos': 7, 'name': 'Ts_phaseA',}, {'pos': 8, 'name': 'Ts_phaseB',}, {'pos': 9, 'name': 'Ts_phaseC',}, {'pos': 10, 'name': 'T1_phaseA',}, {'pos': 11, 'name': 'T1_phaseB',}, {'pos': 12, 'name': 'T1_phaseC',}, {'pos': 13, 'name': 'T2_phaseA',}, {'pos': 14, 'name': 'T2_phaseB',}, {'pos': 15, 'name': 'T2_phaseC',}, {'pos': 16, 'name': 'Ps/100',}, {'pos': 17, 'name': 'Pa/100',}, {'pos': 18, 'name': 'Pb/100',}, {'pos': 19, 'name': 'Pc/100',}, {'pos': 20, 'name': 'Ua/100',}, {'pos': 21, 'name': 'Ub/100',}, {'pos': 22, 'name': 'Uc/100',}, {'pos': 23, 'name': 'Ia/1000',}, {'pos': 24, 'name': 'Ib/1000',}, {'pos': 25, 'name': 'Ic/1000',}, {'pos': 26, 'name': 'Hz/100',}, ] for t in tt_dict: t = Tag(name=t['name'], group_id=1) t.save()
def test_should_create_one_tag_with_same_text(self): tag_name = "tag name" tag1 = Tag(text=tag_name) tag1.save() tags_with_name = Tag.query.filter_by(text=tag_name).all() self.assertEqual(len(tags_with_name), 1) tag2 = Tag.create_unique(tag_name) tags_with_name = Tag.query.filter_by(text=tag_name).all() self.assertEqual(len(tags_with_name), 1) self.assertEqual(tag2, tag1)
def get_tag(name, kind): try: tag = Tag.objects.get(name=name) return tag except ObjectDoesNotExist: kind_obj = None if kind != None: try: kind_obj = TagKind.objects.get(name=kind) except ObjectDoesNotExist: kind_obj = TagKind() kind_obj.name = kind kind_obj.description = "{kind_%s}" % kind kind_obj.icon = "{kind_icon_%s}" % kind kind_obj.save() tag = Tag() tag.name = name tag.kind = kind_obj tag.save() return tag