-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
38 lines (30 loc) · 1.18 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
__author__ = 'kivio'
import unittest
from unittest import TestCase
from stringquery import StringQuery
class StringQueryTest(TestCase):
def setUp(self):
self.sq = None
self.simple_name = "Marcin"
self.simple_surname = "Karkocha"
self.data = "{} {}".format(self.simple_name, self.simple_surname)
self.simple_query = "{name} {surname}"
def assertSimpleQuery(self, result):
self.assertTrue(hasattr(result, 'name'))
self.assertEqual(result.name, self.simple_name)
self.assertTrue(hasattr(result, 'surname'))
self.assertEqual(result.surname, self.simple_surname)
def test_query_and_data_in_constructor(self):
sq = StringQuery(self.simple_query, self.data)
result = sq.query()
self.assertSimpleQuery(result)
def test_query_in_constructor(self):
self.sq = StringQuery(self.simple_query)
result = self.sq.query(self.data)
self.assertSimpleQuery(result)
def test_data_in_constructor(self):
sq = StringQuery(data = self.data)
result = sq.query(query = self.simple_query)
self.assertSimpleQuery(result)
if __name__ == "__main__":
unittest.main()