forked from RitheeshBaradwaj/JenkinsPipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
47 lines (33 loc) · 1.31 KB
/
test.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
import unittest
import xmlrunner
import app
import re
class TestHello(unittest.TestCase):
def setUp(self):
app.app.testing = True
self.app = app.app.test_client()
def test_hello(self):
rv = self.app.get('/')
self.assertEqual(rv.status, '200 OK')
# searching for <h1> tag in the application data using regex
message = rv.data.decode()
start = re.search("<h1>",message).start()
end = re.search("</h1>",message).start()
message = message[start+4:end]
self.assertEqual(message, "hello brother, Lets have some fun!!")
def test_name(self):
name = 'alice'
rv = self.app.get(f'/{name}')
self.assertEqual(rv.status, '200 OK')
# searching for <h1> tag in the application data using regex
message = rv.data.decode()
start = re.search("<h1>",message).start()
end = re.search("</h1>",message).start()
message = message[start+4:end]
self.assertEqual(message, "alice: A nerd")
if __name__ == '__main__':
############# To Generate Test Reports #############
runner = xmlrunner.XMLTestRunner(output='test-reports')
unittest.main(testRunner=runner)
#####################################################
unittest.main()