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
67fe659e
Commit
67fe659e
authored
Aug 01, 2016
by
c24b
Committed by
Romain Loth
Aug 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TEST
parent
577e4739
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
82 deletions
+26
-82
tests_100_toolchain.py
unittests/tests_100_toolchain.py
+26
-82
No files found.
unittests/tests_100_toolchain.py
View file @
67fe659e
#!/usr/bin/python3 env
#!/usr/bin/python3 env
"""
"""
TOOLCHAIN INTEGRATION TESTS
TOOLCHAIN TEST SUITE
================
A set of testing user interaction with datasets
from login to NGRAMSlist creation
integration test from API to BACKEND
add a corpus
"""
"""
#switching to standard testing
#switching to standard testing
from
unittest
import
TestCase
from
unittest
import
TestCase
#make http requests
#make http requests
import
requests
import
requests
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.contrib.auth
import
authenticate
from
django.contrib.auth
import
authenticate
# test Nodes
# test Nodes
from
gargantext.models
import
Node
from
gargantext.models
import
Node
from
gargantext.constants
import
RESOURCETYPES
,
NODETYPES
from
gargantext.constants
import
RESOURCETYPES
,
NODETYPES
...
@@ -24,36 +17,18 @@ from unittests.framework import GargTestRunner
...
@@ -24,36 +17,18 @@ from unittests.framework import GargTestRunner
#API capabilities
#API capabilities
#from rest_framework.test import APIRequestFactory
#from rest_framework.test import APIRequestFactory
class
UserRecipes
(
TestCase
):
def
setUp
(
self
):
#before any test
self
.
session
=
GargTestRunner
.
testdb_session
self
.
client
=
Client
()
def
tearDown
(
self
):
#after any test
pass
def
test_000_create_user
(
self
):
pass
def
test_001_login
(
self
):
pass
def
test_002_authenticate
(
self
):
pass
def
test_003_unlogin
(
self
):
pass
class
ProjectsRecipes
(
TestCase
):
class
ToolChainRecipes
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
#before anytest
self
.
session
=
GargTestRunner
.
testdb_session
self
.
session
=
GargTestRunner
.
testdb_session
self
.
client
=
Client
()
self
.
client
=
Client
()
self
.
source_list
=
[(
resource
[
"type"
],
resource
[
"name"
])
for
resource
in
RESOURCETYPES
]
self
.
source_list
.
insert
(
0
,
(
0
,
"Select a database below"
))
def
tearDown
(
self
):
#after any test
pass
def
_create_projet
(
self
):
def
_create_project
(
self
):
#resp = self.client.post('/projects/', data={"name":"test"})
self
.
project
=
Node
(
self
.
project
=
Node
(
user_id
=
user
.
id
,
user_id
=
user
.
id
,
typename
=
'PROJECT'
,
typename
=
'PROJECT'
,
...
@@ -62,59 +37,28 @@ class ProjectsRecipes(TestCase):
...
@@ -62,59 +37,28 @@ class ProjectsRecipes(TestCase):
session
.
add
(
self
.
project
)
session
.
add
(
self
.
project
)
session
.
commit
()
session
.
commit
()
return
self
.
project
return
self
.
project
def
create_corpus
(
self
,
source
,
name
,
file
):
def
create_test
(
self
):
def
test_001_get_projects
(
self
):
type
=
forms
.
ChoiceField
(
'''get every projects'''
choices
=
source_list
,
resp
=
self
.
client
.
get
(
'/projects/'
)
widget
=
forms
.
Select
(
attrs
=
{
'onchange'
:
'CustomForSelect( $("option:selected", this).text() );'
})
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
test_002_delete_projects
(
self
):
'''delete every projects'''
resp
=
self
.
client
.
delete
(
'/projects/'
)
self
.
assertEqual
(
resp
.
status_code
,
204
)
def
test_003_put_projects
(
self
):
'''modify every projects'''
resp
=
self
.
client
.
put
(
'/projects?name="test"'
)
self
.
assertEqual
(
resp
.
status_code
,
202
)
def
test_004_post_project
(
self
):
'''create a project'''
resp
=
self
.
client
.
post
(
'/projects/'
,
data
=
{
"name"
:
"test"
})
self
.
assertEqual
(
resp
.
status_code
,
201
)
def
test_005_get_project
(
self
):
'''get one project'''
project
=
self
.
_create_projet
()
resp
=
self
.
client
.
delete
(
'/project/'
+
project
.
id
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
test_006_delete_project
(
self
):
'''delete one project'''
project
=
self
.
_create_projet
()
#delete it
resp
=
self
.
client
.
delete
(
'/project/'
+
project
.
id
)
self
.
assertEqual
(
resp
.
status_code
,
204
)
def
test_007_put_project
(
self
):
project
=
self
.
_create_projet
()
resp
=
self
.
client
.
put
(
'/project/'
+
project
.
id
+
"?name=newname"
)
self
.
assertEqual
(
resp
.
status_code
,
204
)
pass
class
CorpusRecipes
(
TestCase
):
def
setUp
(
self
):
self
.
session
=
GargTestRunner
.
testdb_session
self
.
client
=
Client
()
def
_create_project
(
self
):
self
.
project
=
Node
(
user_id
=
user
.
id
,
typename
=
'PROJECT'
,
name
=
"test1"
,
)
)
def
_create_corpus
(
self
):
name
=
forms
.
CharField
(
label
=
'Name'
,
max_length
=
199
,
widget
=
forms
.
TextInput
(
attrs
=
{
'required'
:
'true'
}))
self
.
project
.
add_child
()
file
=
forms
.
FileField
()
def
clean_resource
(
self
):
file_
=
self
.
cleaned_data
.
get
(
'file'
)
def
clean_file
(
self
):
file_
=
self
.
cleaned_data
.
get
(
'file'
)
if
len
(
file_
)
>
1024
**
3
:
# we don't accept more than 1GB
raise
forms
.
ValidationError
(
ugettext_lazy
(
'File too heavy! (>1GB).'
))
return
file_
class
CoporaRecipes
(
TestCase
):
class
CoporaRecipes
(
TestCase
):
...
...
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