-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
52 lines (42 loc) · 1.47 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
import pdb # pdb.set_trace()
import unittest
import random
from app import app, db
from app.mod_auth.models import User, Receta
class TestParticipant(unittest.TestCase):
def setUp(self):
app.config.from_object('config')
db.session.close()
db.drop_all()
db.create_all()
self.app = app.test_client()
# propagate the exceptions to the test client
self.app.testing = True
def test_receta(self):
print ("Receta:")
size= Receta.query.all()
receta = Receta('Lasana bolonesa', '[email protected]','Canelones, cerne, bechamel')
db.session.add(receta)
db.session.commit()
recetas = Receta.query.all()
assert receta in recetas
print (" Inserccion: ok")
assert len(recetas)==len(size)+1
print (" Numero entradas: ok")
def test_usuario(self):
print ("Usuario:")
size= User.query.all()
usuario = User("pepe","[email protected]","123423", 'user', '0')
db.session.add(usuario)
db.session.commit()
usuarios = User.query.all()
assert usuario in usuarios
print (" Inserccion: ok")
assert len(usuarios)==len(size)+1
print (" Numero entradas: ok")
def test_home_status_code(self):
result = self.app.get('auth/todas_recetas',follow_redirects=True)
self.assertEqual(result.status_code, 200)
print (" Url todas_recetas: 200")
if __name__ == '__main__':
unittest.main()