Skip to content

Commit 4537f91

Browse files
committed
Modified the alias factory to work around the problem with the backend collapsing aliases with accented and unaccented versions of the same name.
- Legacy-Id: 11580
1 parent 8b83c72 commit 4537f91

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

ietf/person/factories.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,16 @@ def delete_file(file):
6868
class AliasFactory(factory.DjangoModelFactory):
6969
class Meta:
7070
model = Alias
71-
django_get_or_create = ('name',)
71+
72+
@classmethod
73+
def _create(cls, model_class, *args, **kwargs):
74+
person = kwargs['person']
75+
name = kwargs['name']
76+
existing_aliases = set(model_class.objects.filter(person=person).values_list('name', flat=True))
77+
if not name in existing_aliases:
78+
obj = model_class(*args, **kwargs)
79+
obj.save()
80+
return obj
7281

7382
name = factory.Faker('name')
7483

0 commit comments

Comments
 (0)