-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
77 lines (65 loc) · 2.58 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from opghelper import app
from flask import url_for
import unittest
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
class FlaskTestCase(unittest.TestCase):
def test_index(self):
tester = app.test_client(self)
response = tester.get('/', content_type='html/text')
self.assertEqual(response.status_code, 200)
def test_login_page_loads(self):
tester = app.test_client(self)
response = tester.get('/', content_type='html/text')
self.assertTrue(b'Lozinka' in response.data)
#provjeri login s pravim vrijednostima
def test_login_prave_vrijednosti(self):
tester = app.test_client()
response = tester.post(
'/',
data=dict(korisnicko_ime='admin', password='administrator'),
follow_redirects=True
)
self.assertIn(b'Prijavljeni ste', response.data)
#provjeri login s krivim vrijednostima
def test_login_krive_vrijednosti(self):
tester = app.test_client()
response = tester.post(
'/',
data=dict(korisnicko_ime="wrong", password="wrong"),
follow_redirects=True
)
self.assertIn(b'ime ili lozinka', response.data)
#provjeri logout
def test_logout(self):
tester = app.test_client()
tester.post(
'/',
data={'korisnicko_ime':'admin', 'password':'administrator'},
follow_redirects=True
)
response = tester.get('/logout', follow_redirects=True)
self.assertIn(b'Odjava', response.data)
def test_main_route_requires_login(self):
tester = app.test_client()
response = tester.get('/admin_popis_korisnika', follow_redirects=True)
self.assertIn(b'Morate se prijaviti', response.data)
def test_pretraga(self):
tester = app.test_client(self)
tester.post(
'/',
data={'korisnicko_ime':'admin', 'password':'administrator'},
follow_redirects=True
)
response = tester.get('/admin_popis_korisnika', follow_redirects=True)
self.assertIn(b'Tip', response.data)
def test_oglasiopg(self):
tester = app.test_client()
response = tester.get('/oglasiOpgova', follow_redirects=True)
self.assertIn(b'Proizvodu', response.data)
def test_ucitavanje_apija(self):
tester = app.test_client()
response = tester.get('/opcina/KOPRIVNIČKO-KRIŽEVAČKA')
self.assertIn(b'Virje', response.data)
if __name__ == '__main__':
unittest.main()