Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
ef2a5922
Commit
ef2a5922
authored
Apr 23, 2017
by
luxcem
Browse files
start articles tests
parent
5fbde568
Changes
5
Hide whitespace changes
Inline
Side-by-side
apps/rp/apps.py
View file @
ef2a5922
...
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
class
RpConfig
(
AppConfig
):
name
=
'
rp
'
name
=
"
rp
"
apps/rp/factories.py
View file @
ef2a5922
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"
apps/rp/models/article.py
View file @
ef2a5922
...
...
@@ -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
()
...
...
apps/rp/models/vote.py
View file @
ef2a5922
...
...
@@ -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
):
...
...
apps/rp/tests/test_article.py
0 → 100644
View file @
ef2a5922
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment