tests de la route logout
This commit is contained in:
parent
5780a18182
commit
9bfab1cc34
1 changed files with 82 additions and 77 deletions
159
backend/test.py
159
backend/test.py
|
|
@ -36,12 +36,13 @@ class FlaskTestCase(BaseTestCase):
|
||||||
|
|
||||||
# -- UTILS ---
|
# -- UTILS ---
|
||||||
|
|
||||||
# def login(self, email, password):
|
def login(self, email, password):
|
||||||
# data0 = json.dumps({
|
data0 = {
|
||||||
# "email": email,
|
"email": email,
|
||||||
# "password": password
|
"password": password
|
||||||
# })
|
}
|
||||||
# response = self.client.post('/api/login', data=data0)
|
response = self.client.post('/api/login', json=data0)
|
||||||
|
return response
|
||||||
|
|
||||||
# --- LOGIN ---
|
# --- LOGIN ---
|
||||||
|
|
||||||
|
|
@ -114,88 +115,92 @@ class FlaskTestCase(BaseTestCase):
|
||||||
|
|
||||||
# --- REGISTER ---
|
# --- REGISTER ---
|
||||||
|
|
||||||
def test_register_noFields_statusCode(self):
|
# def test_register_noFields_statusCode(self):
|
||||||
data0 = {}
|
# data0 = {}
|
||||||
response = self.client.post('/api/register', json=data0)
|
# response = self.client.post('/api/register', json=data0)
|
||||||
self.assertEqual(response.status_code, 400)
|
# self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
|
|
||||||
def test_register_noFields_message(self):
|
# def test_register_noFields_message(self):
|
||||||
data0 = {}
|
# data0 = {}
|
||||||
response = self.client.post('/api/register', json=data0)
|
# response = self.client.post('/api/register', json=data0)
|
||||||
self.assertIn('Need', response.json['message'])
|
# self.assertIn('Need', response.json['message'])
|
||||||
|
|
||||||
|
|
||||||
def test_register_emptyFields_statusCode(self):
|
# def test_register_emptyFields_statusCode(self):
|
||||||
data0 = {
|
# data0 = {
|
||||||
"email": "",
|
# "email": "",
|
||||||
"password": "blabla",
|
# "password": "blabla",
|
||||||
"nickname": "blabla"
|
# "nickname": "blabla"
|
||||||
}
|
# }
|
||||||
response = self.client.post('/api/register', json=data0)
|
# response = self.client.post('/api/register', json=data0)
|
||||||
self.assertEqual(response.status_code, 400)
|
# self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
|
|
||||||
def test_register_emptyFields_message(self):
|
# def test_register_emptyFields_message(self):
|
||||||
data0 = {
|
# data0 = {
|
||||||
"email": "",
|
# "email": "",
|
||||||
"password": "blabla",
|
# "password": "blabla",
|
||||||
"nickname": "blabla"
|
# "nickname": "blabla"
|
||||||
}
|
# }
|
||||||
response = self.client.post('/api/register', json=data0)
|
# response = self.client.post('/api/register', json=data0)
|
||||||
self.assertEqual(response.json['message'], 'Empty email and/or password and/or nickname fields.')
|
# self.assertEqual(response.json['message'], 'Empty email and/or password and/or nickname fields.')
|
||||||
|
|
||||||
|
|
||||||
def test_register_alreadyExist_statusCode(self):
|
# def test_register_alreadyExist_statusCode(self):
|
||||||
data0 = {
|
# data0 = {
|
||||||
"email": "riri@gmail.com",
|
# "email": "riri@gmail.com",
|
||||||
"password": "blabla",
|
# "password": "blabla",
|
||||||
"nickname": "blabla"
|
# "nickname": "blabla"
|
||||||
}
|
# }
|
||||||
response = self.client.post('/api/register', json=data0)
|
# response = self.client.post('/api/register', json=data0)
|
||||||
|
# self.assertEqual(response.status_code, 500)
|
||||||
|
|
||||||
|
|
||||||
|
# def test_register_alreadyExist_statusCode(self):
|
||||||
|
# data0 = {
|
||||||
|
# "email": "riri@gmail.com",
|
||||||
|
# "password": "blabla",
|
||||||
|
# "nickname": "blabla"
|
||||||
|
# }
|
||||||
|
# response = self.client.post('/api/register', json=data0)
|
||||||
|
# self.assertIn('already exist', response.json['message'])
|
||||||
|
|
||||||
|
|
||||||
|
# def test_register_success_statusCode(self):
|
||||||
|
# data0 = {
|
||||||
|
# "email": "loulou@gmail.com",
|
||||||
|
# "password": "loulouPass",
|
||||||
|
# "nickname": "Loulou"
|
||||||
|
# }
|
||||||
|
# response = self.client.post('/api/register', json=data0)
|
||||||
|
# self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
|
# def test_register_success_message(self):
|
||||||
|
# data0 = {
|
||||||
|
# "email": "loulou@gmail.com",
|
||||||
|
# "password": "loulouPass",
|
||||||
|
# "nickname": "Loulou"
|
||||||
|
# }
|
||||||
|
# response = self.client.post('/api/register', json=data0)
|
||||||
|
# self.assertEqual(response.json['message'], 'User registered.')
|
||||||
|
|
||||||
|
|
||||||
|
# --- LOGOUT ---
|
||||||
|
|
||||||
|
def test_logout_fail_(self):
|
||||||
|
response = self.client.delete('/api/logout')
|
||||||
self.assertEqual(response.status_code, 500)
|
self.assertEqual(response.status_code, 500)
|
||||||
|
|
||||||
|
|
||||||
def test_register_alreadyExist_statusCode(self):
|
def test_logout_success(self):
|
||||||
data0 = {
|
response = self.login("riri@gmail.com", "ririPass")
|
||||||
"email": "riri@gmail.com",
|
if response.status_code == 200:
|
||||||
"password": "blabla",
|
response = self.client.delete('/api/logout')
|
||||||
"nickname": "blabla"
|
self.assertEqual(response.status_code, 200)
|
||||||
}
|
else:
|
||||||
response = self.client.post('/api/register', json=data0)
|
self.assertEqual(True, False)
|
||||||
self.assertIn('already exist', response.json['message'])
|
|
||||||
|
|
||||||
|
|
||||||
def test_register_success_statusCode(self):
|
|
||||||
data0 = {
|
|
||||||
"email": "loulou@gmail.com",
|
|
||||||
"password": "loulouPass",
|
|
||||||
"nickname": "Loulou"
|
|
||||||
}
|
|
||||||
response = self.client.post('/api/register', json=data0)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
|
|
||||||
def test_register_success_message(self):
|
|
||||||
data0 = {
|
|
||||||
"email": "loulou@gmail.com",
|
|
||||||
"password": "loulouPass",
|
|
||||||
"nickname": "Loulou"
|
|
||||||
}
|
|
||||||
response = self.client.post('/api/register', json=data0)
|
|
||||||
self.assertEqual(response.json['message'], 'User registered.')
|
|
||||||
|
|
||||||
|
|
||||||
# # --- LOGOUT ---
|
|
||||||
|
|
||||||
# def test_logout_fail(self):
|
|
||||||
# response = self.client.delete('/api/logout')
|
|
||||||
# self.assertEqual(response.status_code, 500)
|
|
||||||
|
|
||||||
# def test_logout_success(self):
|
|
||||||
# self.login_user()
|
|
||||||
# response = self.client.delete('/api/logout')
|
|
||||||
# self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
# # --- SELF UPDATE ---
|
# # --- SELF UPDATE ---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue