Added tests for ApcUrl class
This commit is contained in:
parent
5ab3ba221d
commit
fb59e78fda
2 changed files with 30 additions and 0 deletions
0
python_apps/api_clients/tests/__init__.py
Normal file
0
python_apps/api_clients/tests/__init__.py
Normal file
30
python_apps/api_clients/tests/test_apcurl.py
Normal file
30
python_apps/api_clients/tests/test_apcurl.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import unittest
|
||||
from .. api_client import ApcUrl, UrlBadParam, IncompleteUrl
|
||||
|
||||
class TestApcUrl(unittest.TestCase):
|
||||
def test_init(self):
|
||||
url = "/testing"
|
||||
u = ApcUrl(url)
|
||||
self.assertEquals( u.base_url, url)
|
||||
|
||||
def test_params_1(self):
|
||||
u = ApcUrl("/testing/%%key%%")
|
||||
self.assertEquals(u.params(key='val').url(), '/testing/val')
|
||||
|
||||
def test_params_2(self):
|
||||
u = ApcUrl('/testing/%%key%%/%%api%%/more_testing')
|
||||
full_url = u.params(key="AAA",api="BBB").url()
|
||||
self.assertEquals(full_url, '/testing/AAA/BBB/more_testing')
|
||||
|
||||
def test_params_ex(self):
|
||||
u = ApcUrl("/testing/%%key%%")
|
||||
with self.assertRaises(UrlBadParam):
|
||||
u.params(bad_key='testing')
|
||||
|
||||
def test_url(self):
|
||||
u = "one/two/three"
|
||||
self.assertEquals( ApcUrl(u).url(), u )
|
||||
|
||||
def test_url_ex(self):
|
||||
u = ApcUrl('/%%one%%/%%two%%/three').params(two='testing')
|
||||
with self.assertRaises(IncompleteUrl): u.url()
|
Loading…
Add table
Add a link
Reference in a new issue