Skip to content

Commit 675209f

Browse files
author
Christopher Bradshaw
committed
added tests
1 parent 2f588c9 commit 675209f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/test_cert_pinning.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
import sys
5+
import unittest
6+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
7+
import clever
8+
from clever import importer
9+
10+
class CleverTestCase(unittest.TestCase):
11+
def setUp(self):
12+
super(CleverTestCase, self).setUp()
13+
clever.set_api_key('DEMO_KEY')
14+
15+
class CertPinning(CleverTestCase):
16+
17+
def test_prod_api(self):
18+
clever.api_base = 'https://api.clever.com'
19+
district = clever.District.all()[0]
20+
self.assertEqual(district.name, 'Demo District')
21+
22+
def test_staging_api(self):
23+
clever.api_base = 'https://api-staging.ops.clever.com'
24+
district = clever.District.all()[0]
25+
self.assertEqual(district.name, 'Demo District')
26+
27+
def test_cert_failure(self):
28+
try:
29+
clever.api_base = 'https://httpbin.org'
30+
self.assertRaises(clever.APIConnectionError, clever.District.all())
31+
finally:
32+
print 'a'
33+
34+
35+
if __name__ == '__main__':
36+
suite = unittest.TestSuite()
37+
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(CertPinning))
38+
unittest.TextTestRunner(verbosity=3).run(suite)

0 commit comments

Comments
 (0)