Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factories for the ipr app. Coverage of ietf.ipr.views.ajax_search, an…
…d a factory-driven test of ietf.ipr.views.edit. Commit ready for merge. - Legacy-Id: 14970
- Loading branch information
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import datetime | ||
import factory | ||
|
||
|
||
from ietf.ipr.models import ( | ||
IprDisclosureBase, HolderIprDisclosure, ThirdPartyIprDisclosure, NonDocSpecificIprDisclosure, | ||
GenericIprDisclosure, IprDocRel | ||
) | ||
|
||
def _fake_patent_info(): | ||
return "Date: %s\nNotes: %s\nTitle: %s\nNumber: %s\nInventor: %s\n" % ( | ||
(datetime.datetime.today()-datetime.timedelta(days=365)).strftime("%Y-%m-%d"), | ||
factory.Faker('sentence').generate({}), | ||
factory.Faker('sentence').generate({}), | ||
'US9999999', | ||
factory.Faker('name').generate({}), | ||
) | ||
|
||
class IprDisclosureBaseFactory(factory.DjangoModelFactory): | ||
class Meta: | ||
model = IprDisclosureBase | ||
|
||
by = factory.SubFactory('ietf.person.factories.PersonFactory') | ||
compliant = True | ||
holder_legal_name = factory.Faker('name') | ||
state_id='posted' | ||
submitter_name = factory.Faker('name') | ||
submitter_email = factory.Faker('email') | ||
title = factory.Faker('sentence') | ||
|
||
@factory.post_generation | ||
def docs(self, create, extracted, **kwargs): | ||
if not create: | ||
return | ||
if extracted: | ||
for doc in extracted: | ||
IprDocRel.objects.create(disclosure=self,document=doc.docalias_set.first()) | ||
|
||
|
||
class HolderIprDisclosureFactory(IprDisclosureBaseFactory): | ||
class Meta: | ||
model = HolderIprDisclosure | ||
|
||
holder_contact_email = factory.Faker('email') | ||
holder_contact_name = factory.Faker('name') | ||
licensing_id = 'reasonable' | ||
patent_info = _fake_patent_info() | ||
|
||
|
||
class ThirdPartyIprDisclosureFactory(IprDisclosureBaseFactory): | ||
class Meta: | ||
model = ThirdPartyIprDisclosure | ||
|
||
ietfer_name = factory.Faker('name') | ||
ietfer_contact_email = factory.Faker('email') | ||
patent_info = _fake_patent_info() | ||
|
||
|
||
class NonDocSpecificIprDisclosureFactory(IprDisclosureBaseFactory): | ||
class Meta: | ||
model = NonDocSpecificIprDisclosure | ||
|
||
holder_contact_email = factory.Faker('email') | ||
holder_contact_name = factory.Faker('name') | ||
patent_info = _fake_patent_info() | ||
|
||
class GenericIprDisclosureFactory(IprDisclosureBaseFactory): | ||
class Meta: | ||
model = GenericIprDisclosure | ||
|
||
holder_contact_email = factory.Faker('email') | ||
holder_contact_name = factory.Faker('name') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters