2
2
import requests_mock
3
3
from streampot import StreamPot , JobEntity , JobStatus
4
4
5
+
5
6
@pytest .fixture
6
7
def stream_pot ():
7
8
return StreamPot (secret = 'test_secret' )
8
9
10
+
9
11
def test_initialization (stream_pot ):
10
12
assert stream_pot .secret == 'test_secret'
11
13
assert stream_pot .base_url == 'https://api.streampot.io/v1'
12
14
assert isinstance (stream_pot .actions , list )
13
15
assert len (stream_pot .actions ) == 0
14
16
15
- def test_check_status (stream_pot ):
17
+
18
+ def test_get_job (stream_pot ):
16
19
with requests_mock .Mocker () as m :
17
- job_id = ' 123'
20
+ job_id = 123
18
21
mock_url = f"{ stream_pot .base_url } /jobs/{ job_id } "
19
22
mock_response = {'id' : 123 , 'status' : 'completed' , 'created_at' : '2020-01-01' }
20
23
m .get (mock_url , json = mock_response )
21
24
22
- response = stream_pot .check_status (job_id )
25
+ response = stream_pot .get_job (job_id )
23
26
assert response == mock_response
24
27
28
+
25
29
def test_run (stream_pot ):
26
30
with requests_mock .Mocker () as m :
27
31
mock_url = f"{ stream_pot .base_url } /"
@@ -34,15 +38,17 @@ def test_run(stream_pot):
34
38
assert response .status == JobStatus .PENDING
35
39
assert response .created_at == '2020-01-02'
36
40
41
+
37
42
def test_add_action (stream_pot ):
38
43
stream_pot .merge_add ('source_video.mp4' )
39
44
assert len (stream_pot .actions ) == 1
40
45
assert stream_pot .actions [0 ]['name' ] == 'mergeAdd'
41
46
assert stream_pot .actions [0 ]['value' ] == ('source_video.mp4' ,)
42
47
48
+
43
49
@pytest .mark .parametrize ("method, expected_action" , [
44
50
("merge_add" , 'mergeAdd' ),
45
- # ("add_input", 'addInput'),
51
+ ("add_input" , 'addInput' ),
46
52
# add more methods and expected actions as necessary
47
53
])
48
54
def test_actions (stream_pot , method , expected_action ):
0 commit comments