From 6adb9412b8b77c81ef8cc33a0b481885dadb6012 Mon Sep 17 00:00:00 2001 From: Matheus Lins Date: Mon, 5 Sep 2016 04:40:48 -0300 Subject: [PATCH] criando o test de editar perfil --- courses/templates/course/home.html | 23 +++++++++++++++++++++++ logs/log_file_05-09-2016.txt | 18 ++++++++++++++++++ users/forms.py | 8 +++++++- users/tests.py | 35 ++++++++++++++++++++++++++++++++++- users/urls.py | 2 +- 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 courses/templates/course/home.html diff --git a/courses/templates/course/home.html b/courses/templates/course/home.html new file mode 100644 index 0000000..74e8f44 --- /dev/null +++ b/courses/templates/course/home.html @@ -0,0 +1,23 @@ +{% extends 'app/base.html' %} + +{% load static i18n %} +{% load widget_tweaks %} + +{% block breadcrumbs %} + +{% endblock %} + +{% block sidebar %} +
+ + {% trans 'Courses' %} + +
+{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/logs/log_file_05-09-2016.txt b/logs/log_file_05-09-2016.txt index 92a9f7e..bcb48e8 100644 --- a/logs/log_file_05-09-2016.txt +++ b/logs/log_file_05-09-2016.txt @@ -24,3 +24,21 @@ 05/09/2016 04:13:23 - test - Acessou home 05/09/2016 04:15:02 - test - Entrou no sistema 05/09/2016 04:15:02 - test - Acessou home +05/09/2016 04:20:19 - matheuslins - Entrou no sistema +05/09/2016 04:20:19 - matheuslins - Acessou home +05/09/2016 04:21:11 - matheuslins - Acessou home +05/09/2016 04:36:46 - test - Entrou no sistema +05/09/2016 04:36:46 - test - Acessou home +05/09/2016 04:37:23 - test - Entrou no sistema +05/09/2016 04:37:23 - test - Acessou home +05/09/2016 04:37:41 - test - Entrou no sistema +05/09/2016 04:37:41 - test - Acessou home +05/09/2016 04:38:01 - test - Entrou no sistema +05/09/2016 04:38:01 - test - Acessou home +05/09/2016 04:38:23 - test - Entrou no sistema +05/09/2016 04:38:23 - test - Acessou home +05/09/2016 04:38:39 - test - Entrou no sistema +05/09/2016 04:38:39 - test - Acessou home +05/09/2016 04:39:39 - test - Entrou no sistema +05/09/2016 04:39:39 - test - Acessou home +05/09/2016 04:40:28 - matheuslins - Acessou home diff --git a/users/forms.py b/users/forms.py index c91ba5e..b2496bd 100644 --- a/users/forms.py +++ b/users/forms.py @@ -25,4 +25,10 @@ class UserForm(forms.ModelForm): class Meta: model = User - fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'is_staff', 'is_active'] \ No newline at end of file + fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'is_staff', 'is_active'] + +class EditUserForm(forms.ModelForm): + + class Meta: + model = User + fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'cpf', 'phone', 'image'] \ No newline at end of file diff --git a/users/tests.py b/users/tests.py index de8bdc0..0e6e914 100644 --- a/users/tests.py +++ b/users/tests.py @@ -1,3 +1,36 @@ -from django.test import TestCase +from django.test import TestCase, Client +from rolepermissions.shortcuts import assign_role +from django.core.urlresolvers import reverse +from .models import * +from .forms import * # Create your tests here. +class TestCreateUser(TestCase): + + def setUp(self): + self.client = Client() + + self.user = User.objects.create_user( + username = 'test', + email = 'testing@amadeus.com', + is_staff = True, + is_active = True, + password = 'testing' + ) + assign_role(self.user, 'system_admin') + + def test_edit_users(self): + self.client.login(username='test', password='testing') + + url = reverse('users:edit_profile', kwargs={'pk': self.user.id}) + data = EditUserForm(self.data['email']).data + data['email'] = "testing2@amadeus.com" + + response = self.client.put(url, data, format='json') + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data['email'], data['email']) + + + + + diff --git a/users/urls.py b/users/urls.py index c336720..1d8b8d3 100644 --- a/users/urls.py +++ b/users/urls.py @@ -8,5 +8,5 @@ urlpatterns = [ url(r'^usuario/editar/(?P[\w_-]+)/$', views.Update.as_view(), name='update'), url(r'^usuario/dados/(?P[\w_-]+)/$', views.View.as_view(), name='view'), url(r'^perfil/$', views.Profile.as_view(), name='profile'), - url(r'^perfil/editar/$', views.EditProfile.as_view(), name='edit_profile'), + url(r'^perfil/editar/(?P[\w_-]+)/$', views.EditProfile.as_view(), name='edit_profile'), ] -- libgit2 0.21.2