Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
ef2a5922
Commit
ef2a5922
authored
Apr 23, 2017
by
luxcem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start articles tests
parent
5fbde568
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
6 deletions
+39
-6
apps/rp/apps.py
apps/rp/apps.py
+1
-1
apps/rp/factories.py
apps/rp/factories.py
+16
-0
apps/rp/models/article.py
apps/rp/models/article.py
+8
-4
apps/rp/models/vote.py
apps/rp/models/vote.py
+2
-1
apps/rp/tests/test_article.py
apps/rp/tests/test_article.py
+12
-0
No files found.
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
Markdown
is supported
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