Exemple #1
0
def generate_random_shop(
    name=fake.company_suffix(),
    company=fake.company(),
    url=fake.url(),
    platform=fake.pystr(),
    version=fake.pystr(),
    agency=fake.pystr(),
    email=fake.pystr(),
    currencies=None,
    categories=None,
    delivery_options=None,
    pickup_options=None,
    enable_auto_discounts=fake.pybool(),
    offers=None,
    gifts=None,
    promos=None,
) -> "models.Shop":
    if currencies is None:
        currencies = [factories.CurrencyFactory() for _ in range(3)]
    if categories is None:
        categories = [factories.CategoryFactory() for _ in range(3)]
    if delivery_options is None:
        delivery_options = [factories.OptionFactory() for _ in range(3)]
    if pickup_options is None:
        pickup_options = [factories.OptionFactory() for _ in range(3)]
    if offers is None:
        offers = [
            factories.SimplifiedOfferFactory().create(),
            factories.ArbitraryOfferFactory().create(),
            factories.BookOfferFactory().create(),
        ]
    if gifts is None:
        gifts = [factories.GiftFactory() for _ in range(3)]
    if promos is None:
        promos = [factories.Promo() for _ in range(3)]

    return models.Shop(
        name=name,
        company=company,
        url=url,
        platform=platform,
        version=version,
        agency=agency,
        email=email,
        currencies=currencies,
        categories=categories,
        delivery_options=delivery_options,
        pickup_options=pickup_options,
        enable_auto_discounts=enable_auto_discounts,
        offers=offers,
        gifts=gifts,
        promos=promos,
    )
Exemple #2
0
def get_valid_form_data(stall):
    profile = factories.ShippingProfileFactory(stall=stall)
    category = factories.CategoryFactory()
    return {
        "title": "Some Product",
        "description": "This is a productive product",
        "primary_category": category.id,
        "keywords_field": ["keyword1", "keyword2"],
        "shipping_profile": profile.id,
        "status": Product.PUBLISHED_DRAFT,
        "save-publish": True,
    }
Exemple #3
0
def test_category_articles_can_be_updated_when_adding_articles_using_add_articles_by_id_method(
        db):
    factories.CategoryFactory(id='1', articles=1)
    category = Category.query.get('1')
    assert len(category.articles) == 1

    articles = factories.ArticleFactory.create_batch(size=2)
    category.add_articles_by_id(article_ids=[a.id for a in articles])
    db.session.add(category)
    db.session.commit()

    category = Category.query.get('1')
    assert len(category.articles) == 3
 def get(self, **kwargs):
     return factories.CategoryFactory(**kwargs)
def category():
    return factories.CategoryFactory()
Exemple #6
0
 def setUp(self):
     self.cat1 = factories.CategoryFactory(name="cat1")
     self.cat2 = factories.CategoryFactory(name="cat2", parent=self.cat1)
     self.product = factories.ProductFactory(primary_category=self.cat2)
 def setUp(self):
     self.cat1 = factories.CategoryFactory(name="cat1")
     self.cat2 = factories.CategoryFactory(name="cat2", parent=self.cat1)
     self.product = factories.ProductFactory(title="Brand name shampoo",
                                             primary_category=self.cat2)