Exemplo n.º 1
0
    def setUp(self):
        super().setUp()
        self.category = CategoryFactory()
        self.client_1 = ClientFactory()
        AccountFactory.create(user=self.user, client=self.client_1)
        self.product_1, self.product_2 = ProductFactory.create_batch(2, category=self.category)
        self.feature_1 = FeatureFactory(name='Wireless', product=self.product_2,
                                        shared_image=SharedImageFactory(image=ImageField(filename='wireless.jpg')))
        self.feature_2, self.feature_3 = FeatureFactory.create_batch(2, product=self.product_2)
        price_1 = ClientPriceFactory(client=self.client_1, product=self.product_1, unit_cost=200, system_cost=300)
        price_2 = ClientPriceFactory(client=self.client_1, product=self.product_2, unit_cost=250, system_cost=300)
        ClientPriceFactory(client=self.client_1, unit_cost=250, system_cost=300,
                           product=ProductFactory(enabled=False),)
        self.discount_1 = DiscountFactory(
            client_price=price_1, discount_type=VALUE_DISCOUNT, value=50, name='CCO', order=1, percent=0,
            apply_type=ON_DOCTOR_ORDER, cost_type=UNIT_COST,
            shared_image=SharedImageFactory(image=ImageField(filename='CCO.png'))
        )
        self.discount_2 = DiscountFactory(
            client_price=price_2, discount_type=PERCENT_DISCOUNT, percent=10, cost_type=SYSTEM_COST, order=2,
            apply_type=ON_DOCTOR_ORDER, name='Repless',
            shared_image=SharedImageFactory(image=ImageField(filename='repless.png'))
        )
        self.discount_3 = DiscountFactory(
            client_price=price_1, discount_type=PERCENT_DISCOUNT, value=0, name='Bulk', order=2, percent=15,
            apply_type=PRE_DOCTOR_ORDER, cost_type=UNIT_COST, shared_image=None)
        device = self.client_1.device_set.get(product=self.product_1)
        ItemFactory(device=device, discounts=[self.discount_3], purchase_type=BULK_PURCHASE, is_used=False,
                    cost_type=UNIT_COST)

        self.path = reverse('api:hospital:device:products', args=(self.client_1.id, self.category.id,))
Exemplo n.º 2
0
 def setUp(self):
     self.client_1, self.client_2 = ClientFactory.create_batch(2)
     manufacturer = ManufacturerFactory(image=ImageField(
         filename='biotronik.jpg'))
     product = ProductFactory(manufacturer=manufacturer)
     self.item_1 = ItemFactory(cost=randint(110, 150),
                               cost_type=UNIT_COST,
                               device=DeviceFactory(client=self.client_1,
                                                    product=product))
     self.item_2 = ItemFactory(cost=randint(210, 290),
                               cost_type=UNIT_COST,
                               device=DeviceFactory(client=self.client_1))
     self.item_3 = ItemFactory(cost=randint(400, 500),
                               device=DeviceFactory(client=self.client_2))
     self.item_4 = ItemFactory(cost=1000,
                               cost_type=UNIT_COST,
                               device=DeviceFactory(
                                   client=self.client_1,
                                   product=ProductFactory(
                                       manufacturer=manufacturer,
                                       category=product.category)))
     physician_role = RoleFactory(priority=RolePriority.PHYSICIAN.value)
     self.physician_1 = AccountFactory(client=self.client_1,
                                       role=physician_role)
     self.physician_2 = AccountFactory(client=self.client_2,
                                       role=physician_role,
                                       user=self.physician_1.user)
     self.physician_3 = AccountFactory(client=self.client_1,
                                       role=physician_role)
Exemplo n.º 3
0
    def handle(self, *args, **options):
        """Populate database with fake objects."""

        self.stdout.write(self.style.SUCCESS('Creating 15 organizations'))
        for _ in tqdm(range(15)):
            organization = OrganizationFactory.create()
            UserProfileFactory.create(organizations=(organization, ), )

        self.stdout.write(self.style.SUCCESS('Creating 50 offers'))
        for _ in tqdm(range(50)):
            OfferFactory.create(
                organization=random.choice(Organization.objects.all()),
                image__path=ImageField(
                    from_func=placeimg_com_download(1000, 400, 'any')))

        self.stdout.write(self.style.SUCCESS('Creating 150 volunteers'))
        for _ in tqdm(range(150)):
            userprofile = UserProfileFactory.create()
            no_of_offers = random.randrange(10)
            for offer in random.sample(list(Offer.objects.all()),
                                       no_of_offers):
                offer.volunteers.add(userprofile.user)

        self.stdout.write(
            self.style.SUCCESS('Database successfully populated'))
Exemplo n.º 4
0
class ProfileMemberFactory(CleanModelFactory):
    name = FuzzyText()
    role = FuzzyText()
    image = ImageField()

    class Meta:
        model = ProfileMember
Exemplo n.º 5
0
class ArticleFactory(DjangoModelFactory):
    title = Sequence(lambda n: f'Статья {n}')
    text = Faker('text', max_nb_chars=1000)
    image = ImageField()

    class Meta:
        model = 'articles.Article'
Exemplo n.º 6
0
class OfferImageFactory(factory.DjangoModelFactory):
    """Factory for OfferImage."""
    class Meta:  # pylint: disable=C0111
        model = OfferImage

    is_main = True
    path = ImageField(from_func=placeimg_com_download(1000, 400, 'any'))
Exemplo n.º 7
0
class DummyImageFactory(factory.DjangoModelFactory):
    class Meta:
        model = get_image_model()

    title = factory.LazyAttribute(fake_title)
    file = ImageField(from_path=os.path.join(settings.BASE_DIR, 'core',
                                             'static', 'img', 'dummy.jpg'))
Exemplo n.º 8
0
class ImageFactory(CleanModelFactory):
    caption = FuzzyText()
    image = ImageField()
    gallery = SubFactory(GalleryFactory)

    class Meta:
        model = Image
Exemplo n.º 9
0
class ProjectFactory(factory.django.DjangoModelFactory):

    FACTORY_FOR = Project

    name = factory.Sequence(lambda n: 'name%s' % n)
    url = factory.Sequence(lambda n: 'www.rosedu%s.org' % n)
    description = factory.Sequence(lambda n: 'description%s' % n)
    logo = ImageField()
Exemplo n.º 10
0
    def test_uploading_filepath_exists(self):
        SharedImageFactory(name='shock',
                           image=ImageField(filename='test_image.png'))
        uploading_filename = make_imagefield_filepath('shared', self.instance,
                                                      'test_image.png')
        self.assertRegex(uploading_filename, r'shared\/test_image-\d+\.png')

        rmtree(settings.MEDIA_ROOT)
Exemplo n.º 11
0
class AchievementFactory(DjangoModelFactory):
	class Meta:
		model = Achievement

	code = UniqueFaker('bban')
	name = Faker('job')
	image = ImageField(filename='achievement_icon.png')
	description = UniqueFaker('sentence')
Exemplo n.º 12
0
class PersonsFactory(factory.DjangoModelFactory):
    FACTORY_FOR = Persons
    kinopoisk_id = factory.Sequence(lambda i: i)
    name = factory.Sequence(lambda n: u'Персона_{0}'.format(n))
    bio = factory.Sequence(lambda n: u'Биография_{0}'.format(n))
    photo = ImageField(color='red')
    birthdate = datetime.datetime.now()
    city = factory.SubFactory(CitiesFactory)
Exemplo n.º 13
0
class ApplicantFactory(DjangoModelFactory):
    user = SubFactory(UserFactory)
    about = Faker('text')
    biography = Faker('text')
    speaker_experience = Faker('text')
    image = ImageField()

    class Meta:
        model = Applicant
Exemplo n.º 14
0
class CharityFactory(DjangoModelFactory):
    name = Faker("company")
    link = Faker("url")
    description = Faker("text", max_nb_chars=1000)
    how_to_donate = Faker("text", max_nb_chars=300)
    logo = ImageField()

    class Meta:
        model = Charity
Exemplo n.º 15
0
class CuratorFactory(DjangoModelFactory):
    user = factory.SubFactory(UserFactory)
    actor = None
    title = 'visuomenės veikėjas'
    photo = ImageField()

    class Meta:
        model = models.Curator
        django_get_or_create = ('user',)
Exemplo n.º 16
0
def generate_dummy_image(_unused):
    """
    Used for image fields to create a sane default.
    """
    return ContentFile(
        ImageField()._make_data(  # pylint: disable=protected-access
            {'color': 'blue', 'width': 50, 'height': 50, 'format': 'PNG'}
        ), 'test.png'
    )
Exemplo n.º 17
0
class ImageWithTextFactory(CleanModelFactory):
    title = FuzzyText()
    content = FuzzyText()
    image = ImageField()
    background = FuzzyChoice([i[0] for i in BACKGROUND_CHOICES])
    align = FuzzyChoice([i[0] for i in ALIGNMENT_CHOICES])

    class Meta:
        model = ImageWithText
Exemplo n.º 18
0
class FeatureFactory(CleanModelFactory):
    title = FuzzyText()
    content = FuzzyText()
    align = FuzzyChoice([i[0] for i in ALIGNMENT_CHOICES])
    background = FuzzyChoice([i[0] for i in BACKGROUND_CHOICES])
    text_size = FuzzyChoice([i[0] for i in TEXT_SIZE_CHOICES])
    image = ImageField()

    class Meta:
        model = Feature
Exemplo n.º 19
0
class QuoteFactory(CleanModelFactory):
    quote = FuzzyText()
    author = FuzzyText()
    align = FuzzyChoice([i[0] for i in ALIGNMENT_CHOICES])
    background = FuzzyChoice([i[0] for i in BACKGROUND_CHOICES])
    text_size = FuzzyChoice([i[0] for i in TEXT_SIZE_CHOICES])
    image = ImageField()

    class Meta:
        model = Quote
Exemplo n.º 20
0
class BadgeImageConfigurationFactory(DjangoModelFactory):

    FACTORY_FOR = BadgeImageConfiguration

    mode = 'honor'
    icon = ImageField(color='blue',
                      height=50,
                      width=50,
                      filename='test.png',
                      format='PNG')
Exemplo n.º 21
0
class UserFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = User

    name = factory.Faker("name")
    email = factory.LazyAttribute(
        lambda o: '*****@*****.**' % o.name.replace(" ", "."))
    role = FuzzyChoice([obj[0] for obj in Config.CHOICES])
    profile_image = ImageField(filename="new_image.jpg")
    password = factory.PostGenerationMethodCall('set_password', 'test_pass')
Exemplo n.º 22
0
class ProfileFactory(DjangoModelFactory):
    """Factory for Profiles"""

    name = Faker("name")

    image = Faker("file_path", extension="jpg")
    image_small = Faker("file_path", extension="jpg")
    image_medium = Faker("file_path", extension="jpg")

    image_file = ImageField()
    image_small_file = ImageField()
    image_medium_file = ImageField()

    email_optin = Faker("boolean")

    location = Faker("location")

    class Meta:
        model = Profile
Exemplo n.º 23
0
class ImageFactory(CollectionMemberFactory):
    """
    Custom image factory that is almost exactly like the default image
    factory, except all images are part of the Root collection, rather
    than each image being its own collection.
    """
    class Meta:
        model = get_image_model()

    title = "An image"
    file = ImageField()
Exemplo n.º 24
0
class PartyActorFactory(DjangoModelFactory):
    first_name = 'Lietuvos Žaliųjų Partija'
    last_name = ''
    title = 'politinė partija'
    photo = ImageField()
    group = True
    body = factory.SubFactory(BodyFactory, name='Seimas')

    class Meta:
        model = models.Actor
        django_get_or_create = ('first_name',)
Exemplo n.º 25
0
class PersonActorFactory(DjangoModelFactory):
    first_name = 'Mantas'
    last_name = 'Adomėnas'
    title = 'seimo narys'
    photo = ImageField()
    group = False
    body = None

    class Meta:
        model = models.Actor
        django_get_or_create = ('first_name', 'last_name')
Exemplo n.º 26
0
class OfferImageFactory(factory.DjangoModelFactory):
    """Factory for OfferImage."""

    class Meta:  # pylint: disable=C0111
        model = OfferImage

    is_main = True
    path = ImageField(from_path=os.path.join(
        os.path.dirname(__file__),
        'frontend/img/volontulo_baner.png'
    ))
Exemplo n.º 27
0
class OrganizationFactory(DjangoModelFactory):
    name = factory.Sequence(lambda n: f"{faker.word()} #{n}")
    picture = LazyAttribute(
        lambda _: ContentFile(
            ImageField()._make_data({"width": 1024, "height": 768}),
            "example.jpg",
        )
    )

    class Meta:
        model = Organization
Exemplo n.º 28
0
 def setUp(self):
     super().setUp()
     self.product = ProductFactory()
     self.shared_image = SharedImageFactory(name='url', image=ImageField(filename='test_image.jpg'))
     self.category_feature = CategoryFeatureFactory(name='website', category=self.product.category)
     self.feature_1 = FeatureFactory(name='size', value='24/11', product=self.product, category_feature=None)
     self.feature_2 = FeatureFactory(name='website', value='http://biotronik.com', shared_image=self.shared_image,
                                     category_feature=self.category_feature, product=self.product)
     self.feature_3 = FeatureFactory(name='shock', value='yes', shared_image=self.shared_image, product=self.product,
                                     category_feature=None)
     FeatureFactory(product=self.product, value=None)
     self.path = reverse('api:device:features', args=(self.product.id,))
Exemplo n.º 29
0
class PostFactory(DjangoModelFactory):
    class Meta:
        model = Post

    author = SubFactory(UserFactory)
    title = LazyFunction(lambda: fake.text(randint(5, 20)))
    picture = ImageField(color=choice(['blue', 'yellow', 'green', 'orange']),
                         height=randint(250, 1000),
                         width=randint(250, 1000),
                         )
    text = LazyFunction(lambda: fake.text(randint(200, 3000)))
    created_at = LazyFunction(lambda: now() - delta(days=365))
Exemplo n.º 30
0
class PropertyFactory(DjangoModelFactory):
    class Meta:
        model = Property

    title = Sequence(lambda x: u'title %d' % x)
    description = Sequence(lambda x: u'description %d' % x)
    slug = LazyAttribute(lambda a: slugify(a.title))
    address = Sequence(lambda x: u'address %d' % x)
    image = ImageField(color='blue')
    is_available = True
    price = 7
    created_by = SubFactory(UserFactory)