Commit ef2a5922 authored by luxcem's avatar luxcem

start articles tests

parent 5fbde568
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class RpConfig(AppConfig):
name = 'rp'
name = "rp"
import datetime
import pytz
import factory
from factory.fuzzy import FuzzyDateTime
from .models import Article
......@@ -6,7 +10,19 @@ from .models import Article
class ArticleFactory(factory.django.DjangoModelFactory):
class Meta:
model = Article
url = factory.Faker("url")
lang = "en"
title = factory.Faker("sentence", nb_words=4)
website = factory.Sequence(lambda n: "Website {}".format(n))
extracts = factory.Faker("text")
created_at = FuzzyDateTime(
datetime.datetime(2014, 1, 1, tzinfo=pytz.UTC))
updated_at = FuzzyDateTime(
datetime.datetime(2014, 1, 1, tzinfo=pytz.UTC))
published_at = FuzzyDateTime(
datetime.datetime(2014, 1, 1, tzinfo=pytz.UTC))
status = "PENDING"
......@@ -9,23 +9,27 @@ class Article(UnDVotedMixin):
url = models.URLField("URL")
lang = models.CharField(_("Language"), max_length=50, null=True)
metadata = models.TextField(_("Opengraph metadata"), blank=True, null=True)
screenshot = models.ImageField(_("Article screenshot"), blank=True, null=True)
screenshot = models.ImageField(_("Article screenshot"),
blank=True, null=True)
title = models.CharField(_("Article title"), max_length=255, default="")
website = models.CharField(_("Website"), max_length=255, default="")
extracts = models.TextField(_("Content extracts"), blank=True, null=True)
created_at = models.DateTimeField(_("Creation date"), auto_now_add=True)
updated_at = models.DateTimeField(_("Last update"), auto_now=True)
published_at = models.DateTimeField(_("Publication date"), blank=True, null=True)
published_at = models.DateTimeField(_("Publication date"),
blank=True, null=True)
STATUS_CHOICES = (
("PENDING", _("Pending")),
("PUBLISHED", _("Published")),
("REJECTED", _("Rejected"))
)
status = models.CharField(
_("Published"), choices=STATUS_CHOICES, default="PENDING",
max_length=20)
_("Published"), choices=STATUS_CHOICES,
default="PENDING", max_length=20
)
tags = TaggableManager()
......
......@@ -27,7 +27,8 @@ class UnDVotes(models.Model):
verbose_name_plural = _("Votes")
def __str__(self):
return "{}:{}:{}".format(self.username, self.content_object, self.score)
return "{}:{}:{}".format(
self.username, self.content_object, self.score)
class UnDVotedMixin(models.Model):
......
from rp.models import Article
from rp.factories import ArticleFactory
from rp.apps import RpConfig
def test_init():
assert RpConfig.name == "rp"
def test_article():
article = ArticleFactory()
assert type(article) == Article
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment