forked from klinkin/pyunisend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
executable file
·51 lines (34 loc) · 1.34 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# -*- coding:utf8 -*-
import unittest
from pyunisend import PyUniSend
APIKEY = 'add your apikey here'
class SimpleTestCase(unittest.TestCase):
def setUp(self):
self.APIKEY = APIKEY
def testPyUniSendSecure(self):
secure_url = 'https://www.unisender.com/ru/api/'
api = PyUniSend(self.APIKEY, secure=True, test_mode=True)
self.assertEqual(api.base_api_url, secure_url)
def testPyUniSendNoSecure(self):
secure_url = 'http://api.unisender.com/ru/api/'
api = PyUniSend(self.APIKEY, secure=False, test_mode=True)
self.assertEqual(api.base_api_url, secure_url)
class MethodTestCase(unittest.TestCase):
def setUp(self):
self.APIKEY = APIKEY
self.api = PyUniSend(self.APIKEY, secure=True, test_mode=True)
def testMethodGetLists(self):
title = u'Рассылка'
lists = self.api.getLists()
self.assertTrue(title in lists['result'][0]['title'])
def testMethodCreateList(self):
newlist = self.api.createList(title='NewList')
self.assertTrue(newlist['result']['id'] > 0)
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SimpleTestCase))
suite.addTest(unittest.makeSuite(MethodTestCase))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')