Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
67a6c319
Commit
67a6c319
authored
Mar 23, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for getting individual items as well
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
b4c07052
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
8 deletions
+57
-8
weblate/api/tests.py
weblate/api/tests.py
+48
-8
weblate/api/urls.py
weblate/api/urls.py
+9
-0
No files found.
weblate/api/tests.py
View file @
67a6c319
...
...
@@ -34,25 +34,65 @@ class APITest(APITestCase, RepoTestMixin):
response
=
self
.
client
.
get
(
reverse
(
'api:project-list'
)
)
self
.
assertEqual
(
len
(
response
.
data
),
1
)
self
.
assertEqual
(
response
.
data
[
0
][
'slug'
],
'test'
)
self
.
assertEqual
(
response
.
data
[
'count'
],
1
)
self
.
assertEqual
(
response
.
data
[
'results'
][
0
][
'slug'
],
'test'
)
def
test_get_project
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:project-detail'
,
kwargs
=
{
'slug'
:
'test'
})
)
self
.
assertEqual
(
response
.
data
[
'slug'
],
'test'
)
def
test_list_components
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:subproject-list'
)
reverse
(
'api:component-list'
)
)
self
.
assertEqual
(
response
.
data
[
'count'
],
1
)
self
.
assertEqual
(
response
.
data
[
'results'
][
0
][
'slug'
],
'test'
)
self
.
assertEqual
(
response
.
data
[
'results'
][
0
][
'project'
][
'slug'
],
'test'
)
def
test_get_component
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:component-detail'
,
kwargs
=
{
'slug'
:
'test'
,
'project__slug'
:
'test'
}
)
)
self
.
assertEqual
(
len
(
response
.
data
),
1
)
self
.
assertEqual
(
response
.
data
[
0
][
'slug'
],
'test'
)
self
.
assertEqual
(
response
.
data
[
0
][
'project'
][
'slug'
],
'test'
)
self
.
assertEqual
(
response
.
data
[
'slug'
],
'test'
)
self
.
assertEqual
(
response
.
data
[
'project'
][
'slug'
],
'test'
)
def
test_list_translations
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:translation-list'
)
)
self
.
assertEqual
(
len
(
response
.
data
),
3
)
self
.
assertEqual
(
response
.
data
[
'count'
],
3
)
def
test_get_translation
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:translation-detail'
,
kwargs
=
{
'language__code'
:
'cs'
,
'subproject__slug'
:
'test'
,
'subproject__project__slug'
:
'test'
}
)
)
self
.
assertEqual
(
response
.
data
[
'language_code'
],
'cs'
)
def
test_list_languages
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:language-list'
)
)
self
.
assertEqual
(
len
(
response
.
data
),
3
)
self
.
assertEqual
(
response
.
data
[
'count'
],
3
)
def
test_get_language
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'api:language-detail'
,
kwargs
=
{
'code'
:
'cs'
})
)
self
.
assertEqual
(
response
.
data
[
'name'
],
'Czech'
)
weblate/api/urls.py
View file @
67a6c319
...
...
@@ -33,6 +33,11 @@ router.register(
r'projects'
,
ProjectViewSet
)
router
.
register
(
r'components'
,
ComponentViewSet
,
'component'
,
)
router
.
register
(
r'components/(?P<project__slug>[^/]+)'
,
ComponentViewSet
,
...
...
@@ -44,6 +49,10 @@ router.register(
r'(?P<subproject__slug>[^/]+)'
,
TranslationViewSet
)
router
.
register
(
r'translations'
,
TranslationViewSet
)
router
.
register
(
r'languages'
,
LanguageViewSet
...
...
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