Skip to content

Commit

Permalink
Merge pull request #143 from fga-gpp-mds/devel
Browse files Browse the repository at this point in the history
TS13-StandardizeTests
  • Loading branch information
maugustoo authored Nov 5, 2017
2 parents 1c7758d + a536e02 commit 751b542
Show file tree
Hide file tree
Showing 65 changed files with 441 additions and 789 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def setUp(self):
self.view.object = self.message
self.view.user = self.user

def test_get_success_url_true(self):
def test_chat_get_success_url_true(self):
self.assertEqual(self.view.get_success_url(), '/pt-br/chat/view_message_health_professional/1')

def test_get_succes_url_false(self):
def test_chat_get_succes_url_false(self):
self.message.pk = '2'
self.assertNotEqual(self.view.get_success_url(), '/pt-br/chat/view_message_health_professional/1')
8 changes: 4 additions & 4 deletions medical_prescription/chat/test/test_form_create_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ def setUp(self):
self.text_max = 'a'*1000
self.email_invalid = 'a2d'

def test_valid(self):
def test_chat_valid(self):
form_data = {'subject': self.subject,
'text': self.text,
'user_to': self.email
}
form = CreateMessage(data=form_data)
self.assertTrue(form.is_valid())

def test_invalid_subject(self):
def test_chat_invalid_subject(self):
form_data = {'subject': self.subject_max,
'text': self.text,
}
form = CreateMessage(data=form_data)
self.assertFalse(form.is_valid())

def test_invalid_text(self):
def test_chat_invalid_text(self):
form_data = {'subject': self.subject,
'text': self.text_max,
}
form = CreateMessage(data=form_data)
self.assertFalse(form.is_valid())

def test_invalid_email(self):
def test_chat_invalid_email(self):
form_data = {'subject': self.subject,
'text': self.text,
'user_to': self.email_invalid
Expand Down
4 changes: 2 additions & 2 deletions medical_prescription/chat/test/test_forms_create_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def setUp(self):
self.text_max = 'a'*1000
self.email_invalid = 'a2d'

def test_valid(self):
def test_chat_valid(self):
form_data = {
'text': self.text,
'user_to': self.email
}
form = self.form_class(data=form_data)
self.assertTrue(form.is_valid())

def test_invalid_text(self):
def test_chat_invalid_text(self):
form_data = {'text': self.text_max}
form = self.form_class(data=form_data)
self.assertFalse(form.is_valid())
4 changes: 2 additions & 2 deletions medical_prescription/chat/test/test_view_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def setUp(self):
self.health_professional = User.objects.create_user(email='[email protected]',
password='teste')

def test_request_autocomplete_cid_fail(self):
def test_chat_request_autocomplete_cid_fail(self):
request = self.factory.get('/chat/ajax/autocomplete_email/?search=test')
request.user = self.health_professional
response = AutoCompleteEmail.as_view()(request)
self.assertNotEquals(response, HttpResponse)

def test_request_autocomplete_cid_return_one_disease(self):
def test_chat_request_autocomplete_cid_return_one_disease(self):
request = self.factory.get('/chat/ajax/autocomplete_email/?search=test',
HTTP_X_REQUESTED_WITH='XMLHttpRequest')

Expand Down
6 changes: 3 additions & 3 deletions medical_prescription/chat/test/test_view_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def setUp(self):
self.my_view_class = ComposeView
self.client = Client()

def test_get(self):
def test_chat_get(self):
request = self.factory.get('/chat/compose/')
request.user = self.user
response = self.my_view.get(request)
self.assertEqual(response.status_code, 200)

def test_post(self):
def test_chat_post(self):
request = self.factory.post('chat/compose',
{'text': 'isso e um texto',
'subject': 'test suject',
Expand All @@ -45,7 +45,7 @@ def test_post(self):
response = self.my_view_class.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_post_invalid(self):
def test_chat_post_invalid(self):
request = self.factory.post('chat/compose',
{'text': 'a'*10000,
'subject': 'test suject',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUp(self):
self.message.user_to = self.patient
self.message.save()

def test_query_true(self):
def test_chat_query_true(self):
request = self.factory.get('/chat/compose/')
request.user = self.patient

Expand All @@ -47,7 +47,7 @@ def test_query_true(self):

self.assertTrue(query.exists())

def test_query_false(self):
def test_chat_query_false(self):
request = self.factory.get('/chat/compose/')
request.user = self.professional

Expand Down
4 changes: 2 additions & 2 deletions medical_prescription/chat/test/test_view_inbox_patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):
self.message.user_to = self.professional
self.message.save()

def test_query_true(self):
def test_chat_query_true(self):
request = self.factory.get('/chat/compose/')
request.user = self.professional

Expand All @@ -42,7 +42,7 @@ def test_query_true(self):

self.assertTrue(query.exists())

def test_query_false(self):
def test_chat_query_false(self):
request = self.factory.get('/chat/compose/')
request.user = self.patient

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ def setUp(self):
self.message.pk = '1'
self.message.save()

def test_queryset_true(self):
def test_chat_queryset_true(self):
request = self.view_class.as_view()
request.user = self.user

self.view.request = request
query = self.view.get_queryset()
self.assertTrue(query.exists())

def test_get_context_true(self):
def test_chat_get_context_true(self):
request = self.factory.get('/')
request.user = self.user
self.view.request = request
self.view.object = self.message
self.assertEqual(type(self.view.get_context_data()), type(dict()))

def test_post_true(self):
def test_chat_post_true(self):
request = self.factory.post('/',
{'text': 'isso e um texto',
'user_to': '[email protected]',
Expand All @@ -54,7 +54,7 @@ def test_post_true(self):
response = self.view_class.as_view()(request, pk=1)
self.assertEqual(response.status_code, 302)

def test_post_false(self):
def test_chat_post_false(self):
request = self.factory.post('/',
{'user_to': '[email protected]',
'user_from': '[email protected]'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def setUp(self):
self.view.object = self.message
self.view.user = self.user

def test_get_success_url_true(self):
def test_chat_get_success_url_true(self):
self.assertEqual(self.view.get_success_url(), '/pt-br/chat/view_message_patient/1')

def test_get_succes_url_false(self):
def test_chat_get_succes_url_false(self):
self.message.pk = '2'
self.assertNotEqual(self.view.get_success_url(), '/pt-br/chat/view_message_patient/1')
4 changes: 2 additions & 2 deletions medical_prescription/chat/test/test_view_outbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setUp(self):
self.factory = RequestFactory()
self.view = OutboxView()

def test_query_set_true(self):
def test_chat_query_set_true(self):
request = self.factory.get('chat/outbox')
request.user = self.professional

Expand All @@ -38,7 +38,7 @@ def test_query_set_true(self):
query = self.view.get_queryset()
self.assertTrue(query.exists())

def test_query_set_false(self):
def test_chat_query_set_false(self):
request = self.factory.get('chat/outbox')
request.user = self.professional2

Expand Down
8 changes: 4 additions & 4 deletions medical_prescription/chat/test/test_view_send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ def setUp(self):
self.message.pk = '1'
self.message.save()

def test_queryset_true(self):
def test_chat_queryset_true(self):
request = self.view_class.as_view()
request.user = self.user

self.view.request = request
query = self.view.get_queryset()
self.assertTrue(query.exists())

def test_get_context_true(self):
def test_chat_get_context_true(self):
request = self.factory.get('/')
request.user = self.user
self.view.request = request
self.view.object = self.message
self.assertEqual(type(self.view.get_context_data()), type(dict()))

def test_post_true(self):
def test_chat_post_true(self):
request = self.factory.post('/',
{'text': 'isso e um texto',
'user_to': '[email protected]',
Expand All @@ -54,7 +54,7 @@ def test_post_true(self):
response = self.view_class.as_view()(request, pk=1)
self.assertEqual(response.status_code, 302)

def test_post_false(self):
def test_chat_post_false(self):
request = self.factory.post('/',
{'user_to': '[email protected]',
'user_from': '[email protected]'})
Expand Down
1 change: 1 addition & 0 deletions medical_prescription/disease/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import *
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth.models import AnonymousUser

# Local Django imports
from .views import ListDisease
from disease.views import ListDisease
from user.views import LoginView
from user.models import User, Patient, HealthProfessional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,42 @@ def setUp(self):
custom_exam.health_professional_FK = user
custom_exam.save()

def test_valid(self):
def teste_exam_valid(self):
form_data = {'name': self.name_valid,
'description': self.description_valid
}
form = CreateCustomExams(data=form_data)
self.assertTrue(form.is_valid())

def test_invalid_max_name(self):
def teste_exam_invalid_max_name(self):
form_data = {'name': self.name_max,
'description': self.description_valid
}
form = CreateCustomExams(data=form_data)
self.assertFalse(form.is_valid())

def test_invalid_min_name(self):
def teste_exam_invalid_min_name(self):
form_data = {'name': self.name_min,
'description': self.description_valid
}
form = CreateCustomExams(data=form_data)
self.assertFalse(form.is_valid())

def test_invalid_max_description(self):
def teste_exam_invalid_max_description(self):
form_data = {'name': self.name_valid,
'description': self.description_max
}
form = CreateCustomExams(data=form_data)
self.assertFalse(form.is_valid())

def test_invalid_min_description(self):
def teste_exam_invalid_min_description(self):
form_data = {'name': self.name_valid,
'description': self.description_min
}
form = CreateCustomExams(data=form_data)
self.assertFalse(form.is_valid())

def test_invalid_exists_name(self):
def teste_exam_invalid_exists_name(self):
form_data = {'name': self.name_exists,
'description': self.description_valid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setUp(self):
custom_exam.pk = 1
custom_exam.save()

def test_valid(self):
def teste_exam_valid(self):
form_data = {'name': self.name_valid,
'description': self.description_valid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,53 @@ def setUp(self):
self.user = User.objects.create_user(email='[email protected]', password='senha12')
self.description = "Examina alguma coisa"

def test_get_without_login(self):
def teste_exam_get_without_login(self):
request = self.factory.get('/exam/create_custom_exams/')
request.user = AnonymousUser()

response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_get_with_patient(self):
def teste_exam_get_with_patient(self):
request = self.factory.get('/exam/create_custom_exams/')
request.user = self.patient

response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_get_with_user(self):
def teste_exam_get_with_user(self):
request = self.factory.get('/exam/create_custom_exams/')
request.user = self.user

response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_get_with_health_professional(self):
def teste_exam_get_with_health_professional(self):
request = self.factory.get('/exam/create_custom_exams/')
request.user = self.health_professional

response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 200)

def test_post_without_login(self):
def teste_exam_post_without_login(self):
request = self.factory.post('/exam/create_custom_exams/', {'name': '', 'description': self.description})
request.user = AnonymousUser()
response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_post_with_patient(self):
def teste_exam_post_with_patient(self):
request = self.factory.post('/exam/create_custom_exams/', {'name': '', 'description': self.description})
request.user = self.patient
response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_post_with_user(self):
def teste_exam_post_with_user(self):
request = self.factory.post('/exam/create_custom_exams/', {'name': '', 'description': self.description})
request.user = self.user
response = CreateCustomExamsView.as_view()(request)
self.assertEqual(response.status_code, 302)

def test_post_with_health_professional(self):
def teste_exam_post_with_health_professional(self):
request = self.factory.post('/exam/create_custom_exams/', {'name': '', 'description': self.description})
request.user = self.health_professional
response = CreateCustomExamsView.as_view()(request)
Expand Down
Loading

0 comments on commit 751b542

Please sign in to comment.