Commit 6adb9412b8b77c81ef8cc33a0b481885dadb6012

Authored by Matheus Lins
1 parent e1e948bd

criando o test de editar perfil

courses/templates/course/home.html 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +{% extends 'app/base.html' %}
  2 +
  3 +{% load static i18n %}
  4 +{% load widget_tweaks %}
  5 +
  6 +{% block breadcrumbs %}
  7 + <ol class="breadcrumb">
  8 + <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li>
  9 + <li class="active">{% trans 'Home Course' %}</li>
  10 + </ol>
  11 +{% endblock %}
  12 +
  13 +{% block sidebar %}
  14 + <div class="list-group">
  15 + <a href="{% url 'course:manage' %}" class="list-group-item">
  16 + {% trans 'Courses' %}
  17 + </a>
  18 + </div>
  19 +{% endblock %}
  20 +
  21 +{% block content %}
  22 +
  23 +{% endblock %}
... ...
logs/log_file_05-09-2016.txt
... ... @@ -24,3 +24,21 @@
24 24 05/09/2016 04:13:23 - test - Acessou home
25 25 05/09/2016 04:15:02 - test - Entrou no sistema
26 26 05/09/2016 04:15:02 - test - Acessou home
  27 +05/09/2016 04:20:19 - matheuslins - Entrou no sistema
  28 +05/09/2016 04:20:19 - matheuslins - Acessou home
  29 +05/09/2016 04:21:11 - matheuslins - Acessou home
  30 +05/09/2016 04:36:46 - test - Entrou no sistema
  31 +05/09/2016 04:36:46 - test - Acessou home
  32 +05/09/2016 04:37:23 - test - Entrou no sistema
  33 +05/09/2016 04:37:23 - test - Acessou home
  34 +05/09/2016 04:37:41 - test - Entrou no sistema
  35 +05/09/2016 04:37:41 - test - Acessou home
  36 +05/09/2016 04:38:01 - test - Entrou no sistema
  37 +05/09/2016 04:38:01 - test - Acessou home
  38 +05/09/2016 04:38:23 - test - Entrou no sistema
  39 +05/09/2016 04:38:23 - test - Acessou home
  40 +05/09/2016 04:38:39 - test - Entrou no sistema
  41 +05/09/2016 04:38:39 - test - Acessou home
  42 +05/09/2016 04:39:39 - test - Entrou no sistema
  43 +05/09/2016 04:39:39 - test - Acessou home
  44 +05/09/2016 04:40:28 - matheuslins - Acessou home
... ...
users/forms.py
... ... @@ -25,4 +25,10 @@ class UserForm(forms.ModelForm):
25 25  
26 26 class Meta:
27 27 model = User
28   - fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'is_staff', 'is_active']
29 28 \ No newline at end of file
  29 + fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'type_profile', 'cpf', 'phone', 'image', 'is_staff', 'is_active']
  30 +
  31 +class EditUserForm(forms.ModelForm):
  32 +
  33 + class Meta:
  34 + model = User
  35 + fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'cpf', 'phone', 'image']
30 36 \ No newline at end of file
... ...
users/tests.py
1   -from django.test import TestCase
  1 +from django.test import TestCase, Client
  2 +from rolepermissions.shortcuts import assign_role
  3 +from django.core.urlresolvers import reverse
  4 +from .models import *
  5 +from .forms import *
2 6  
3 7 # Create your tests here.
  8 +class TestCreateUser(TestCase):
  9 +
  10 + def setUp(self):
  11 + self.client = Client()
  12 +
  13 + self.user = User.objects.create_user(
  14 + username = 'test',
  15 + email = 'testing@amadeus.com',
  16 + is_staff = True,
  17 + is_active = True,
  18 + password = 'testing'
  19 + )
  20 + assign_role(self.user, 'system_admin')
  21 +
  22 + def test_edit_users(self):
  23 + self.client.login(username='test', password='testing')
  24 +
  25 + url = reverse('users:edit_profile', kwargs={'pk': self.user.id})
  26 + data = EditUserForm(self.data['email']).data
  27 + data['email'] = "testing2@amadeus.com"
  28 +
  29 + response = self.client.put(url, data, format='json')
  30 + self.assertEqual(response.status_code, 200)
  31 + self.assertEqual(response.data['email'], data['email'])
  32 +
  33 +
  34 +
  35 +
  36 +
... ...
users/urls.py
... ... @@ -8,5 +8,5 @@ urlpatterns = [
8 8 url(r'^usuario/editar/(?P<username>[\w_-]+)/$', views.Update.as_view(), name='update'),
9 9 url(r'^usuario/dados/(?P<username>[\w_-]+)/$', views.View.as_view(), name='view'),
10 10 url(r'^perfil/$', views.Profile.as_view(), name='profile'),
11   - url(r'^perfil/editar/$', views.EditProfile.as_view(), name='edit_profile'),
  11 + url(r'^perfil/editar/(?P<username>[\w_-]+)/$', views.EditProfile.as_view(), name='edit_profile'),
12 12 ]
... ...