diff --git a/ietf/api/tests.py b/ietf/api/tests.py index 5dd1823e72..24d76a6a96 100644 --- a/ietf/api/tests.py +++ b/ietf/api/tests.py @@ -581,6 +581,7 @@ def test_person_export(self): url = urlreverse('ietf.api.views.PersonalInformationExportView') login_testing_unauthorized(self, person.user.username, url) r = self.client.get(url) + self.assertEqual(r.status_code, 200) jsondata = r.json() data = jsondata['person.person'][str(person.id)] self.assertEqual(data['name'], person.name) diff --git a/ietf/doc/factories.py b/ietf/doc/factories.py index a8c20b6bb9..3ea9f2b8fa 100644 --- a/ietf/doc/factories.py +++ b/ietf/doc/factories.py @@ -35,6 +35,7 @@ def draft_name_generator(type_id,group,n): class BaseDocumentFactory(factory.django.DjangoModelFactory): class Meta: model = Document + skip_postgeneration_save = True title = factory.Faker('sentence',nb_words=5) abstract = factory.Faker('paragraph', nb_sentences=5) @@ -329,6 +330,7 @@ class ReviewFactory(BaseDocumentFactory): class DocAliasFactory(factory.django.DjangoModelFactory): class Meta: model = DocAlias + skip_postgeneration_save = True @factory.post_generation def document(self, create, extracted, **kwargs): @@ -378,6 +380,7 @@ def desc(self): class StateDocEventFactory(DocEventFactory): class Meta: model = StateDocEvent + skip_postgeneration_save = True type = 'changed_state' state_type_id = 'draft-iesg' @@ -451,6 +454,7 @@ class WgDocumentAuthorFactory(DocumentAuthorFactory): class BofreqEditorDocEventFactory(DocEventFactory): class Meta: model = BofreqEditorDocEvent + skip_postgeneration_save = True type = "changed_editors" doc = factory.SubFactory('ietf.doc.factories.BofreqFactory') @@ -465,10 +469,12 @@ def editors(obj, create, extracted, **kwargs): else: obj.editors.set(PersonFactory.create_batch(3)) obj.desc = f'Changed editors to {", ".join(obj.editors.values_list("name",flat=True)) or "(None)"}' + obj.save() class BofreqResponsibleDocEventFactory(DocEventFactory): class Meta: model = BofreqResponsibleDocEvent + skip_postgeneration_save = True type = "changed_responsible" doc = factory.SubFactory('ietf.doc.factories.BofreqFactory') @@ -483,7 +489,8 @@ def responsible(obj, create, extracted, **kwargs): else: ad = RoleFactory(group__type_id='area',name_id='ad').person obj.responsible.set([ad]) - obj.desc = f'Changed responsible leadership to {", ".join(obj.responsible.values_list("name",flat=True)) or "(None)"}' + obj.desc = f'Changed responsible leadership to {", ".join(obj.responsible.values_list("name",flat=True)) or "(None)"}' + obj.save() class BofreqFactory(BaseDocumentFactory): type_id = 'bofreq' diff --git a/ietf/group/factories.py b/ietf/group/factories.py index 8968b9b4c1..0be81b9654 100644 --- a/ietf/group/factories.py +++ b/ietf/group/factories.py @@ -25,6 +25,7 @@ class GroupFactory(factory.django.DjangoModelFactory): class Meta: model = Group django_get_or_create = ('acronym',) + skip_postgeneration_save = True name = factory.Faker('sentence',nb_words=6) acronym = factory.Sequence(lambda n: 'acronym%d' %n) @@ -87,6 +88,7 @@ class DatelessGroupMilestoneFactory(BaseGroupMilestoneFactory): class GroupHistoryFactory(factory.django.DjangoModelFactory): class Meta: model=GroupHistory + skip_postgeneration_save = True time = lambda: timezone.now() group = factory.SubFactory(GroupFactory, state_id='active') @@ -138,6 +140,7 @@ class Meta: class AppealArtifactFactory(factory.django.DjangoModelFactory): class Meta: model=AppealArtifact + skip_postgeneration_save = True appeal = factory.SubFactory(AppealFactory) artifact_type = factory.SubFactory("ietf.name.factories.AppealArtifactTypeNameFactory", slug="appeal") @@ -158,4 +161,5 @@ def set_bits(obj, create, extracted, **kwargs): if isinstance(using, str): using = using.encode("utf-8") obj.bits = memoryview(using) + obj.save() diff --git a/ietf/ietfauth/factories.py b/ietf/ietfauth/factories.py index b68b0cecef..5e827791a1 100644 --- a/ietf/ietfauth/factories.py +++ b/ietf/ietfauth/factories.py @@ -14,6 +14,7 @@ class OidClientRecordFactory(factory.django.DjangoModelFactory): class Meta: model = OidClientRecord + skip_postgeneration_save = True name = factory.Faker('company') owner = factory.SubFactory(UserFactory) diff --git a/ietf/ipr/factories.py b/ietf/ipr/factories.py index d4a1f2eb4e..ca48b32d02 100644 --- a/ietf/ipr/factories.py +++ b/ietf/ipr/factories.py @@ -26,6 +26,7 @@ def _fake_patent_info(): class IprDisclosureBaseFactory(factory.django.DjangoModelFactory): class Meta: model = IprDisclosureBase + skip_postgeneration_save = True by = factory.SubFactory('ietf.person.factories.PersonFactory') compliant = True diff --git a/ietf/liaisons/factories.py b/ietf/liaisons/factories.py index 61788817eb..6e5500889d 100644 --- a/ietf/liaisons/factories.py +++ b/ietf/liaisons/factories.py @@ -6,6 +6,7 @@ class LiaisonStatementFactory(factory.django.DjangoModelFactory): class Meta: model = LiaisonStatement + skip_postgeneration_save = True title = factory.Faker('sentence') from_contact = factory.SubFactory('ietf.person.factories.EmailFactory') diff --git a/ietf/meeting/factories.py b/ietf/meeting/factories.py index 87f0ef2e1f..69c1f0421b 100644 --- a/ietf/meeting/factories.py +++ b/ietf/meeting/factories.py @@ -23,6 +23,7 @@ class MeetingFactory(factory.django.DjangoModelFactory): class Meta: model = Meeting + skip_postgeneration_save = True type_id = factory.Iterator(['ietf','interim']) @@ -103,6 +104,7 @@ def group_conflicts(obj, create, extracted, **kwargs): # pulint: disable=no-sel class SessionFactory(factory.django.DjangoModelFactory): class Meta: model = Session + skip_postgeneration_save = True meeting = factory.SubFactory(MeetingFactory) purpose_id = 'regular' @@ -156,6 +158,7 @@ class Meta: class RoomFactory(factory.django.DjangoModelFactory): class Meta: model = Room + skip_postgeneration_save = True meeting = factory.SubFactory(MeetingFactory) name = factory.Faker('name') @@ -172,6 +175,7 @@ def session_types(obj, create, extracted, **kwargs): # pylint: disable=no-self-a class TimeSlotFactory(factory.django.DjangoModelFactory): class Meta: model = TimeSlot + skip_postgeneration_save = True meeting = factory.SubFactory(MeetingFactory) type_id = 'regular' @@ -225,6 +229,7 @@ class Meta: class SlideSubmissionFactory(factory.django.DjangoModelFactory): class Meta: model = SlideSubmission + skip_postgeneration_save = True session = factory.SubFactory(SessionFactory) title = factory.Faker('sentence') @@ -238,6 +243,7 @@ class Meta: class ConstraintFactory(factory.django.DjangoModelFactory): class Meta: model = Constraint + skip_postgeneration_save = True meeting = factory.SubFactory(MeetingFactory) source = factory.SubFactory(GroupFactory) diff --git a/ietf/nomcom/factories.py b/ietf/nomcom/factories.py index 6fd6819b0b..7999228c24 100644 --- a/ietf/nomcom/factories.py +++ b/ietf/nomcom/factories.py @@ -84,6 +84,7 @@ def nomcom_kwargs_for_year(year=None, *args, **kwargs): class NomComFactory(factory.django.DjangoModelFactory): class Meta: model = NomCom + skip_postgeneration_save = True group = factory.SubFactory(GroupFactory,type_id='nomcom') @@ -167,6 +168,7 @@ class Meta: class FeedbackFactory(factory.django.DjangoModelFactory): class Meta: model = Feedback + skip_postgeneration_save = True nomcom = factory.SubFactory(NomComFactory) subject = factory.Faker('sentence') @@ -176,6 +178,7 @@ class Meta: def comments(obj, create, extracted, **kwargs): comment_text = Faker().paragraph() obj.comments = obj.nomcom.encrypt(comment_text) + obj.save() class TopicFactory(factory.django.DjangoModelFactory): class Meta: diff --git a/ietf/person/factories.py b/ietf/person/factories.py index 4761a3f4ef..2247fa9b2b 100644 --- a/ietf/person/factories.py +++ b/ietf/person/factories.py @@ -46,6 +46,7 @@ class Meta: model = User django_get_or_create = ('username',) exclude = ['faker', ] + skip_postgeneration_save = True faker = factory.LazyFunction(random_faker) # normalize these i18n Unicode strings in the same way the database does @@ -55,13 +56,16 @@ class Meta: slugify(unidecode(u.last_name)), n, fake.domain_name())) # type: ignore username = factory.LazyAttribute(lambda u: u.email) + # Consider using PostGenerationMethodCall instead @factory.post_generation def set_password(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument obj.set_password( '%s+password' % obj.username ) # pylint: disable=no-value-for-parameter + obj.save() class PersonFactory(factory.django.DjangoModelFactory): class Meta: model = Person + skip_postgeneration_save = True user = factory.SubFactory(UserFactory) name = factory.LazyAttribute(lambda p: normalize_name('%s %s'%(p.user.first_name, p.user.last_name))) @@ -106,6 +110,7 @@ def default_photo(obj, create, extracted, **kwargs): # pylint: disable=no-self-a def delete_file(file): os.unlink(file) atexit.register(delete_file, photodst) + obj.save() class AliasFactory(factory.django.DjangoModelFactory): class Meta: diff --git a/ietf/review/factories.py b/ietf/review/factories.py index d6780fad80..158251317e 100644 --- a/ietf/review/factories.py +++ b/ietf/review/factories.py @@ -11,6 +11,7 @@ class ReviewTeamSettingsFactory(factory.django.DjangoModelFactory): class Meta: model = ReviewTeamSettings + skip_postgeneration_save = True group = factory.SubFactory('ietf.group.factories.GroupFactory',type_id='review') reviewer_queue_policy_id = 'RotateAlphabetically' diff --git a/requirements.txt b/requirements.txt index f56e703bd1..89bfb4431a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ django-widget-tweaks>=1.4.12 djlint>=1.0.0 # To auto-indent templates via "djlint --profile django --reformat" docutils>=0.18.1 # Used only by dbtemplates for RestructuredText types-docutils>=0.18.1 -factory-boy>=3.2.1,<3.3 +factory-boy>=3.3 github3.py>=3.2.0 gunicorn>=20.1.0 hashids>=1.3.1