Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
1fa6dee7
Commit
1fa6dee7
authored
Sep 05, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unittests: re-add api tests (merci c24b) for later
parent
08dc385e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
tests_071_api.py
unittests/todo/tests_071_api.py
+86
-0
No files found.
unittests/todo/tests_071_api.py
0 → 100644
View file @
1fa6dee7
"""
API UNIT TESTS
================
"""
from
django.test
import
TestCase
,
Client
from
gargantext.models
import
Node
from
gargantext.util.db
import
session
from
rest_framework.test
import
APIClient
from
rest_framework.test
import
APIRequestFactory
# Using the standard RequestFactory API to create a form POST request
#factory = APIRequestFactory()
class
APIRecipe
(
TestCase
):
def
setUp
(
self
):
"""
Will be run before each test
"""
self
.
client
=
Client
()
# login with our fake user
response
=
self
.
client
.
post
(
'/auth/login/'
,
{
'username'
:
'pcorser'
,
'password'
:
'peter'
}
)
self
.
create_project
()
self
.
create_corpus
()
self
.
factory
=
APIRequestFactory
()
def
create_project
(
self
):
new_project
=
Node
(
typename
=
'PROJECT'
,
name
=
"My project"
,
)
session
.
add
(
new_project
)
session
.
commit
()
self
.
project
=
new_project
def
create_corpus
(
self
):
#create a default corpus
self
.
corpus
=
self
.
project
.
add_child
(
name
=
"My Corpus"
,
typename
=
'CORPUS'
,
)
session
.
add
(
self
.
corpus
)
session
.
commit
()
def
test_001_post_project
(
self
):
'''POST /projects'''
request
=
self
.
factory
.
post
(
'/api/projects/'
,
{
'name'
:
'PROJECT TEST'
},
format
=
'json'
)
def
test_002_get_projects
(
self
):
'''GET /projects'''
request
=
self
.
factory
.
get
(
'/api/projects/'
,
format
=
'json'
)
def
test_003_put_projects
(
self
):
'''PUT /projects'''
request
=
self
.
factory
.
put
(
'/api/projects/'
,
{
"name"
:
"My TEST PROJECT"
},
format
=
'json'
)
def
test_004_delete_projects
(
self
):
'''DELETE /projects'''
request
=
self
.
factory
.
delete
(
'/api/projects/'
,
format
=
'json'
)
def
test_005_delete_project
(
self
):
'''DELETE /project'''
request
=
self
.
factory
.
delete
(
'/api/project/
%
s'
%
self
.
project
.
id
,
format
=
'json'
)
def
test_006_get_project
(
self
):
'''GET /PROJECT'''
request
=
self
.
factory
.
get
(
'/api/project/
%
s'
%
self
.
project
.
id
,
format
=
'json'
)
def
test_007_put_project
(
self
):
''' PUT /PROJECT '''
request
=
self
.
factory
.
put
(
'/api/project/
%
s'
%
self
.
project
.
id
,
{
"name"
:
"My New Project"
},
format
=
'json'
)
# def test_008_post_corpus(self):
# '''POST /project'''
# request = self.factory.post('/project/', {'name': 'PROJECT TEST'})
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