Example #1
0
class BaseReportsFactory(BaseFactory):
    committee_id = factory.LazyAttribute(
        lambda o: CommitteeFactory().committee_id)
Example #2
0
class RiskAssessmentFactory(TitledFactory):
    class Meta:
        model = all_models.RiskAssessment

    status = "Draft"
    program = factory.LazyAttribute(lambda _: ProgramFactory())
Example #3
0
class UserFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = User

    username = factory.Sequence(lambda n: "user%d" % n)
    email = factory.LazyAttribute(lambda obj: "*****@*****.**" % obj.username)
Example #4
0
class StandardFactory(TitledFactory):
    """Standard factory class"""
    class Meta:
        model = all_models.Standard

    description = factory.LazyAttribute(lambda _: random_str(length=100))
Example #5
0
class ReviewFactory(ModelFactory):
    class Meta:
        model = all_models.Review

    reviewable = factory.LazyAttribute(lambda _: ControlFactory())
    notification_type = all_models.Review.NotificationTypes.EMAIL_TYPE
Example #6
0
class IssueTrackerIssueFactory(TitledFactory):
    class Meta:
        model = all_models.IssuetrackerIssue

    issue_tracked_obj = factory.LazyAttribute(lambda m: AssessmentFactory())
    issue_id = factory.LazyAttribute(lambda _: random.randint(1, 1000))
Example #7
0
class ProgramFactory(TitledFactory):
    class Meta:
        model = all_models.Program

    context = factory.LazyAttribute(lambda _: ContextFactory())
Example #8
0
class InventoryFactory(factory.django.DjangoModelFactory):
    made_at = factory.LazyAttribute(lambda o: datetime.datetime.utcnow())

    class Meta:
        model = Inventory
Example #9
0
class StripeCustomerFactory(ModelFactory):
    class Meta:
        model = StripeCustomer

    stripe_customer_id = factory.LazyAttribute(lambda _: f"cus_{fake.uuid4()}")
Example #10
0
class GeoLevelFactory(MongoEngineFactory):
    class Meta:
        model = GeoLevel

    id = factory.LazyAttribute(lambda o: unique_string())
    name = factory.Faker('name')
Example #11
0
class FileFactory(factory.django.DjangoModelFactory):
    file = factory.LazyAttribute(lambda x: choice(File.PATHS)[0])

    class Meta:
        model = File
        django_get_or_create = ('file', )
Example #12
0
class SpatialCoverageFactory(MongoEngineFactory):
    class Meta:
        model = SpatialCoverage

    geom = factory.Faker('multipolygon')
    granularity = factory.LazyAttribute(random_spatial_granularity)
class ArticleFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Article
        django_get_or_create = ('title', 'path')

    path = factory.Sequence(
        lambda n: u'00010{}'.format(n))  # Article sequence starts from 0001020
    depth = 2
    numchild = 0
    title = "Article Page"
    slug = factory.LazyAttribute(lambda obj: slugify(obj.title))
    live = True
    has_unpublished_changes = False
    seo_title = " "
    show_in_menus = False
    search_description = " "
    go_live_at = '2011-10-24 12:43'
    expire_at = '2050-12-31 12:43'
    expired = False
    content_type = factory.SubFactory(ContentTypeFactory,
                                      app_label="article",
                                      model="article")
    locked = False
    latest_revision_created_at = '2011-10-24 12:43'
    first_published_at = '2011-10-24 12:43'

    strap = "Article strap"
    content = "<p> Article Content ok </p>"

    show_modular_content = False
    modular_content = '[{"type": "paragraph", "value": {"content": "<p>This is a test</p>", "align_content": "default"}}, {"type": "n_column_paragraph", "value": {"paragraph": [{"content": "<p>A test that make test</p>", "align_content": "default"}]}}, {"type": "n_column_paragraph", "id": "f9908f13-68ad-4eb5-9943-5e1cd92a944a", "value": {"paragraph": [{"content": "<p>A test that make test</p>", "align_content": "default"}]}}]'

    language = "en"

    @classmethod
    def _setup_next_sequence(cls):
        return getattr(cls, 'starting_seq_num', 20)

    @factory.post_generation
    def featured_image(self, create, extracted, **kwargs):
        if not create:
            return

        if extracted:
            self.featured_image = extracted

    @factory.post_generation
    def authors(self, create, extracted, **kwargs):
        if not create:
            return

        if extracted:
            for author in extracted:
                self.authors.add(author)

    @factory.post_generation
    def categories(self, create, extracted, **kwargs):
        if not create:
            return

        if extracted:
            for category in extracted:
                self.categories.add(category)

    @factory.post_generation
    def locations(self, create, extracted, **kwargs):
        if not create:
            return

        if extracted:
            for location in extracted:
                self.locations.add(location)
Example #14
0
class CustomImageFactory(factory.DjangoModelFactory):
    title = factory.sequence(lambda x: "extended-image-{0}".format([x]))
    file = factory.LazyAttribute(lambda x: get_test_image_file())

    class Meta:
        model = CustomImage
Example #15
0
class GeoLevelFactory(MongoEngineFactory):
    class Meta:
        model = models.GeoLevel

    id = factory.LazyAttribute(lambda o: unique_string())
    name = factory.LazyAttribute(lambda o: faker.name())
Example #16
0
class PollFactory(factory.DjangoModelFactory):
    class Meta:
        model = models.Poll

    question = factory.Faker("sentence")
    pub_date = factory.LazyAttribute(lambda __: timezone.now())
Example #17
0
class ControlFactory(TitledFactory):
    class Meta:
        model = all_models.Control

    directive = factory.LazyAttribute(lambda m: RegulationFactory())
    recipients = ""
Example #18
0
class HumanFactory(factory.Factory):
    class Meta:
        model = Human

    name = factory.LazyAttribute(lambda x: faker.name())
Example #19
0
class AssessmentFactory(TitledFactory):
    class Meta:
        model = all_models.Assessment

    audit = factory.LazyAttribute(lambda m: AuditFactory())
Example #20
0
class DatasetDiscussionFactory(MongoEngineFactory):
    class Meta:
        model = models.DatasetDiscussion

    title = factory.LazyAttribute(lambda o: faker.sentence())
Example #21
0
class PersonFactory(ModelFactory):
    class Meta:
        model = all_models.Person

    email = factory.LazyAttribute(
        lambda _: random_str(chars=string.ascii_letters) + "@example.com")
Example #22
0
class OrganizationFactory(MongoEngineFactory):
    class Meta:
        model = models.Organization

    name = factory.LazyAttribute(lambda o: faker.sentence())
    description = factory.LazyAttribute(lambda o: faker.text())
Example #23
0
class ProposalFactory(ModelFactory):
    class Meta:
        model = all_models.Proposal

    proposed_by = factory.LazyAttribute(lambda _: PersonFactory())
    content = None
Example #24
0
class LicenseFactory(MongoEngineFactory):
    class Meta:
        model = models.License

    id = factory.LazyAttribute(lambda o: faker.word())
    title = factory.LazyAttribute(lambda o: faker.sentence())
Example #25
0
class TitledFactory(ModelFactory):
    title = factory.LazyAttribute(lambda m: random_str(prefix='title '))
Example #26
0
class SpatialCoverageFactory(MongoEngineFactory):
    class Meta:
        model = models.SpatialCoverage

    geom = factory.LazyAttribute(lambda o: faker.multipolygon())
    granularity = factory.LazyAttribute(random_spatial_granularity)
Example #27
0
class PersonWithoutUserFactory(PersonFactory):
    user = None
    first_name = factory.Faker('first_name')
    last_name = factory.Faker('last_name')
    email = factory.LazyAttribute(generate_person_email)
Example #28
0
class TransferFactory(MongoEngineFactory):
    class Meta:
        model = models.Transfer

    comment = factory.LazyAttribute(lambda o: faker.sentence())
Example #29
0
class UserFavouriteEventFactory(BaseFactory):
    class Meta:
        model = UserFavouriteEvent

    user = factory.LazyAttribute(lambda a: User.query.first())
    event = factory.SubFactory(EventFactoryBasic)
Example #30
0
class BaseTotalsFactory(BaseFactory):
    committee_id = factory.LazyAttribute(
        lambda o: CommitteeFactory().committee_id)
    cycle = 2016