import factory

from newsreader.accounts.tests.factories import UserFactory
from newsreader.news.collection.choices import RuleTypeChoices
from newsreader.news.collection.models import CollectionRule


class CollectionRuleFactory(factory.django.DjangoModelFactory):
    name = factory.Sequence(lambda n: "CollectionRule-{}".format(n))
    url = factory.Faker("url")
    website_url = factory.Faker("url")

    category = factory.SubFactory(
        "newsreader.news.core.tests.factories.CategoryFactory"
    )

    user = factory.SubFactory(UserFactory)

    class Meta:
        model = CollectionRule


class FeedFactory(CollectionRuleFactory):
    type = RuleTypeChoices.feed
