Skip to content
Snippets Groups Projects
Commit 2c7d1b71 authored by Stéphane Schoorens's avatar Stéphane Schoorens
Browse files

add upload video tests refs #29848

parent 90c375b4
No related branches found
No related tags found
No related merge requests found
*.mp4 filter=lfs diff=lfs merge=lfs -text
......@@ -4,11 +4,9 @@ pod is a video cms for educational https://github.com/EsupPortail/Esup-Pod
# Client API
all rest resources will be create on PodClient object and usable like that:
all rest resources will be create on PodClient object and usable like that (HOST and API_KEY are vars that contains the base pod url and an authentication token):
```
#!/usr/bin/env python3
pod_client = PodClient(HOST, API_KEY)
# fetch all videos
pod_client.videos.get()
......@@ -16,6 +14,14 @@ pod_client.videos.get()
pod_client.videos.get(resource_id=1)
```
Example to send a video
```
pod_client = PodClient(HOST, API_KEY)
response = pod_client.videos.post(data={'title': 'unittest video', 'type': '%s/rest/types/1/' % HOST, 'owner': '%s/rest/users/1/' % HOST}, files={'video': open(VIDEO_PATH, 'rb')})
```
# build
`make build`
......
File added
......@@ -8,6 +8,7 @@ from pod_client.resource import Resource, API_URLS
HOST = 'http://pod.ubicast.net'
API_KEY = os.environ.get('POD_UNIT_TEST_API_KEY')
VIDEO_PATH = 'tests/media/test.mp4'
def setUpModule():
......@@ -40,3 +41,13 @@ class PodClientTest(TestCase):
self.assertFalse(success)
self.assertTrue(pod_client.videos.get())
def test_post_video(self):
pod_client = PodClient(HOST, API_KEY)
print(pod_client.types.get().json())
response = pod_client.videos.post(data={'title': 'unittest video', 'type': '%s/rest/types/1/' % HOST, 'owner': '%s/rest/users/1/' % HOST}, files={'video': open(VIDEO_PATH, 'rb')})
self.assertEqual(response.status_code, 201, response.text)
data = response.json()
self.assertEqual(data['title'], 'unittest video')
response = pod_client.videos.delete(resource_id=data['id'])
self.assertEqual(response.status_code, 204, response.text)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment