Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-pod-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public-projects
python-pod-client
Commits
b3fc9528
Commit
b3fc9528
authored
5 years ago
by
Stéphane Schoorens
Browse files
Options
Downloads
Patches
Plain Diff
add post channel test refs #29848
parent
2467b974
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pod_client/Resource.py
+29
-25
29 additions, 25 deletions
pod_client/Resource.py
tests/test_resource.py
+18
-10
18 additions, 10 deletions
tests/test_resource.py
with
47 additions
and
35 deletions
pod_client/Resource.py
+
29
−
25
View file @
b3fc9528
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import
os
import
requests
import
logging
API_URLS
=
{
"
users
"
:
"
/rest/users/
"
,
"
groups
"
:
"
/rest/groups/
"
,
"
owners
"
:
"
/rest/owners/
"
,
"
channels
"
:
"
/rest/channels/
"
,
"
themes
"
:
"
/rest/themes/
"
,
"
types
"
:
"
/rest/types/
"
,
"
discipline
"
:
"
/rest/discipline/
"
,
"
videos
"
:
"
/rest/videos/
"
,
"
renditions
"
:
"
/rest/renditions/
"
,
"
encodings_video
"
:
"
/rest/encodings_video/
"
,
"
encodings_audio
"
:
"
/rest/encodings_audio/
"
,
"
playlist_videos
"
:
"
/rest/playlist_videos/
"
,
"
contributors
"
:
"
/rest/contributors/
"
,
"
documents
"
:
"
/rest/documents/
"
,
"
tracks
"
:
"
/rest/tracks/
"
,
"
overlays
"
:
"
/rest/overlays/
"
,
"
chapters
"
:
"
/rest/chapters/
"
,
"
recording
"
:
"
/rest/recording/
"
,
"
recordingfile
"
:
"
/rest/recordingfile/
"
,
"
folders
"
:
"
/rest/folders/
"
,
"
files
"
:
"
/rest/files/
"
,
"
images
"
:
"
/rest/images/
"
,
"
enrichments
"
:
"
/rest/enrichments/
"
,
"
buildings
"
:
"
/rest/buildings/
"
,
"
broadcasters
"
:
"
/rest/broadcasters/
"
'
users
'
:
'
/rest/users/
'
,
'
groups
'
:
'
/rest/groups/
'
,
'
owners
'
:
'
/rest/owners/
'
,
'
channels
'
:
'
/rest/channels/
'
,
'
themes
'
:
'
/rest/themes/
'
,
'
types
'
:
'
/rest/types/
'
,
'
discipline
'
:
'
/rest/discipline/
'
,
'
videos
'
:
'
/rest/videos/
'
,
'
renditions
'
:
'
/rest/renditions/
'
,
'
encodings_video
'
:
'
/rest/encodings_video/
'
,
'
encodings_audio
'
:
'
/rest/encodings_audio/
'
,
'
playlist_videos
'
:
'
/rest/playlist_videos/
'
,
'
contributors
'
:
'
/rest/contributors/
'
,
'
documents
'
:
'
/rest/documents/
'
,
'
tracks
'
:
'
/rest/tracks/
'
,
'
overlays
'
:
'
/rest/overlays/
'
,
'
chapters
'
:
'
/rest/chapters/
'
,
'
recording
'
:
'
/rest/recording/
'
,
'
recordingfile
'
:
'
/rest/recordingfile/
'
,
#'enrichments': '/rest/enrichments/', seems not available in rest api
#'buildings': '/rest/buildings/',
#'broadcasters': '/rest/broadcasters/'
}
if
os
.
environ
.
get
(
'
POD_CLIENT_USE_POD_FILE
'
):
# specific rest urls only available if USE_PODFILE is set in pod settings file
API_URLS
[
'
folders
'
]
=
'
/rest/folders/
'
API_URLS
[
'
files
'
]
=
'
/rest/files/
'
API_URLS
[
'
images
'
]
=
'
/rest/images/
'
class
Resource
:
host_url
=
''
...
...
This diff is collapsed.
Click to expand it.
tests/test_resource.py
+
18
−
10
View file @
b3fc9528
...
...
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import
os
from
unittest
import
TestCase
from
pod_client.Resource
import
Resource
from
pod_client.Resource
import
Resource
,
API_URLS
HOST
=
'
http://pod.ubicast.net
'
API_KEY
=
os
.
environ
.
get
(
'
POD_UNIT_TEST_API_KEY
'
)
...
...
@@ -19,7 +19,7 @@ def tearDownModule():
class
ResourceTest
(
TestCase
):
def
test_init
(
self
):
resource_name
=
'
file
s
'
resource_name
=
'
video
s
'
resource_file
=
Resource
(
HOST
,
API_KEY
,
resource_name
)
self
.
assertEqual
(
HOST
,
resource_file
.
host_url
)
self
.
assertEqual
(
resource_name
,
resource_file
.
name
)
...
...
@@ -43,16 +43,24 @@ class ResourceTest(TestCase):
self
.
assertFalse
(
success
)
def
test_get
(
self
):
resource
=
Resource
(
HOST
,
API_KEY
,
'
videos
'
)
response
=
resource
.
get
()
self
.
assertEqual
(
response
.
status_code
,
200
,
response
.
text
)
first_id
=
response
.
json
().
get
(
'
results
'
,
[])[
0
].
get
(
'
id
'
)
self
.
assertTrue
(
first_id
)
response
=
resource
.
get
(
resource_id
=
first_id
)
self
.
assertEqual
(
response
.
status_code
,
200
,
response
.
text
)
for
resource_name
in
API_URLS
:
resource
=
Resource
(
HOST
,
API_KEY
,
resource_name
)
response
=
resource
.
get
()
self
.
assertEqual
(
response
.
status_code
,
200
,
response
.
text
)
if
response
.
json
().
get
(
'
results
'
,
[]):
first_id
=
response
.
json
().
get
(
'
results
'
,
[])[
0
].
get
(
'
id
'
)
self
.
assertTrue
(
first_id
)
response
=
resource
.
get
(
resource_id
=
first_id
)
self
.
assertEqual
(
response
.
status_code
,
200
,
response
.
text
)
def
test_post
(
self
):
pass
resource
=
Resource
(
HOST
,
API_KEY
,
'
channels
'
)
response
=
resource
.
post
(
data
=
{
'
title
'
:
'
unittest
'
})
self
.
assertEqual
(
response
.
status_code
,
201
,
response
.
text
)
data
=
response
.
json
()
self
.
assertTrue
(
data
[
'
id
'
])
response
=
resource
.
delete
(
resource_id
=
data
[
'
id
'
])
self
.
assertEqual
(
response
.
status_code
,
204
,
response
.
text
)
def
test_put
(
self
):
pass
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment