Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit 1370163

Browse files
committed
Add header
1 parent 71f346c commit 1370163

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tests/test.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class TestWayScript( TestCase ):
1313
program_id = 1234
1414
variables = [ 'one', 'two', 'three' ]
1515
api_url = 'https://wayscript.com/api'
16+
headers = { 'X-WayScript-Api': 'python' }
1617

1718
def test_api_key( self ):
1819
with self.assertRaises( InvalidApiKeyException ):
@@ -30,7 +31,8 @@ def test_run_program( self ):
3031
wayscript.run_program( self.program_id )
3132
post_request.assert_called_once_with( self.api_url, params = { 'api_key': self.dummy_api_key,
3233
'program_id': self.program_id,
33-
'run_async': False } )
34+
'run_async': False },
35+
headers = self.headers )
3436

3537
def test_run_program_with_variables( self ):
3638
wayscript = WayScript( self.dummy_api_key )
@@ -40,7 +42,8 @@ def test_run_program_with_variables( self ):
4042
post_request.assert_called_once_with( self.api_url, params = { 'api_key': self.dummy_api_key,
4143
'program_id': self.program_id,
4244
'run_async': False,
43-
'variables': self.variables } )
45+
'variables': self.variables },
46+
headers = self.headers )
4447

4548
def test_run_program_async( self ):
4649
wayscript = WayScript( self.dummy_api_key )
@@ -50,7 +53,8 @@ def test_run_program_async( self ):
5053
post_request.assert_called_once_with( self.api_url, params = { 'api_key': self.dummy_api_key,
5154
'program_id': self.program_id,
5255
'run_async': True,
53-
'variables': self.variables } )
56+
'variables': self.variables },
57+
headers = self.headers )
5458

5559
def test_empty_variables( self ):
5660
wayscript = WayScript( self.dummy_api_key )
@@ -59,7 +63,8 @@ def test_empty_variables( self ):
5963
wayscript.run_program( self.program_id, variables = [ ], run_async = True )
6064
post_request.assert_called_once_with( self.api_url, params = { 'api_key': self.dummy_api_key,
6165
'program_id': self.program_id,
62-
'run_async': True } )
66+
'run_async': True },
67+
headers = self.headers )
6368

6469
def test_returns_response( self ):
6570
wayscript = WayScript( self.dummy_api_key )
@@ -68,5 +73,6 @@ def test_returns_response( self ):
6873
response = wayscript.run_program( self.program_id, run_async = True )
6974
post_request.assert_called_once_with( self.api_url, params = { 'api_key': self.dummy_api_key,
7075
'program_id': self.program_id,
71-
'run_async': True } )
76+
'run_async': True },
77+
headers = self.headers )
7278
self.assertEqual( response, 'ok' )

wayscript/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ def run_program( self, program_id, variables = None, run_async = False ):
4747
return self._post( params )
4848

4949
def _post( self, params ):
50-
return requests.post( self._api_url, params = params )
50+
headers = { 'X-WayScript-Api': 'python' }
51+
return requests.post( self._api_url, params = params, headers = headers )

0 commit comments

Comments
 (0)