{"action":"created","comment":{"url":"https://api.github.com/repos/interlegis/sapl/pulls/comments/60944480","id":60944480,"diff_hunk":"@@ -0,0 +1,74 @@\n+# -*- coding: utf-8 -*-\n+import pytest\n+from django.contrib.auth.models import User\n+from django.test.html import parse_html as html\n+\n+\n+pytestmark = pytest.mark.django_db\n+\n+@pytest.fixture\n+def user():\n+    return User.objects.create_user('jfirmino', password='123')\n+\n+def test_login_aparece_na_barra_para_usuario_nao_logado(client):\n+    response = client.get('/')\n+    assert '<a href=\"/login/?next=/\">Login</a>' in response.content\n+\n+def test_username_do_usuario_logado_aparece_na_barra(client, user):\n+    assert client.login(username='jfirmino', password='123')\n+    response = client.get('/')\n+    assert html('<a href=\"/login/?next=/\">Login</a>') not in html(response.content)\n+    assert 'jfirmino' in response.content\n+    assert html('<a href=\"/logout/?next=/\">Sair</a>') in html(response.content)\n+\n+def test_nome_completo_do_usuario_logado_aparece_na_barra(client, user):\n+    # nome completo para o usuario\n+    user.first_name = 'Joao'\n+    user.last_name = 'Firmino'\n+    user.save()\n+    assert client.login(username='jfirmino', password='123')\n+    response = client.get('/')\n+    assert html('<a href=\"/login/?next=/\">Login</a>') not in html(response.content)\n+    assert 'Joao Firmino' in response.content\n+    assert html('<a href=\"/logout/?next=/\">Sair</a>') in html(response.content)\n+\n+@pytest.mark.parametrize(\"link_login,destino\", [\n+    # login a partir de uma pagina retorna para ela mesma\n+    ('/login/?next=/zzzz', 'http://testserver/zzzz'),\n+    ('/login/?next=/', 'http://testserver/'),\n+    # login a partir da propria pagina de login redireciona para home\n+    ('/login/?next=/login/', 'http://testserver/'),\n+    # link sem destino de retorno (next) redireciona para home\n+    ('/login/', 'http://testserver/'),\n+])\n+def test_login(app, user, link_login, destino):\n+    pagina_login = app.get(link_login)\n+    form = pagina_login.forms['login-form']\n+    form['username'] = 'jfirmino'\n+    form['password'] = '123'\n+    res = form.submit()\n+\n+    assert user.pk == app.session['_auth_user_id']\n+    assert res.url == destino","path":"base/tests/test_login.py","position":52,"original_position":52,"commit_id":"45379a8eb078c62449df299a7c0d88f590c92ce8","original_commit_id":"45379a8eb078c62449df299a7c0d88f590c92ce8","user":{"login":"edwardoliveira","id":9326037,"avatar_url":"https://avatars.githubusercontent.com/u/9326037?v=3","gravatar_id":"","url":"https://api.github.com/users/edwardoliveira","html_url":"https://github.com/edwardoliveira","followers_url":"https://api.github.com/users/edwardoliveira/followers","following_url":"https://api.github.com/users/edwardoliveira/following{/other_user}","gists_url":"https://api.github.com/users/edwardoliveira/gists{/gist_id}","starred_url":"https://api.github.com/users/edwardoliveira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edwardoliveira/subscriptions","organizations_url":"https://api.github.com/users/edwardoliveira/orgs","repos_url":"https://api.github.com/users/edwardoliveira/repos","events_url":"https://api.github.com/users/edwardoliveira/events{/privacy}","received_events_url":"https://api.github.com/users/edwardoliveira/received_events","type":"User","site_admin":false},"body":"Mensagem de erro: \r\n\r\n``E       assert '/' == 'http://testserver/'``\r\n\r\n","created_at":"2016-04-25T16:33:27Z","updated_at":"2016-04-25T16:33:27Z","html_url":"https://github.com/interlegis/sapl/pull/328#discussion_r60944480","pull_request_url":"https://api.github.com/repos/interlegis/sapl/pulls/328","_links":{"self":{"href":"https://api.github.com/repos/interlegis/sapl/pulls/comments/60944480"},"html":{"href":"https://github.com/interlegis/sapl/pull/328#discussion_r60944480"},"pull_request":{"href":"https://api.github.com/repos/interlegis/sapl/pulls/328"}}},"pull_request":{"url":"https://api.github.com/repos/interlegis/sapl/pulls/328","id":67031997,"html_url":"https://github.com/interlegis/sapl/pull/328","diff_url":"https://github.com/interlegis/sapl/pull/328.diff","patch_url":"https://github.com/interlegis/sapl/pull/328.patch","issue_url":"https://api.github.com/repos/interlegis/sapl/issues/328","number":328,"state":"open","locked":false,"title":"Fix #316 316 login simples","user":{"login":"eduardocalil","id":14843060,"avatar_url":"https://avatars.githubusercontent.com/u/14843060?v=3","gravatar_id":"","url":"https://api.github.com/users/eduardocalil","html_url":"https://github.com/eduardocalil","followers_url":"https://api.github.com/users/eduardocalil/followers","following_url":"https://api.github.com/users/eduardocalil/following{/other_user}","gists_url":"https://api.github.com/users/eduardocalil/gists{/gist_id}","starred_url":"https://api.github.com/users/eduardocalil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduardocalil/subscriptions","organizations_url":"https://api.github.com/users/eduardocalil/orgs","repos_url":"https://api.github.com/users/eduardocalil/repos","events_url":"https://api.github.com/users/eduardocalil/events{/privacy}","received_events_url":"https://api.github.com/users/eduardocalil/received_events","type":"User","site_admin":false},"body":"Fix #316 ","created_at":"2016-04-19T14:49:02Z","updated_at":"2016-04-25T16:33:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5aac8980bd6a0650cc7701212965e54180472bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/interlegis/sapl/pulls/328/commits","review_comments_url":"https://api.github.com/repos/interlegis/sapl/pulls/328/comments","review_comment_url":"https://api.github.com/repos/interlegis/sapl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/interlegis/sapl/issues/328/comments","statuses_url":"https://api.github.com/repos/interlegis/sapl/statuses/45379a8eb078c62449df299a7c0d88f590c92ce8","head":{"label":"interlegis:316-login-simples","ref":"316-login-simples","sha":"45379a8eb078c62449df299a7c0d88f590c92ce8","user":{"login":"interlegis","id":1484001,"avatar_url":"https://avatars.githubusercontent.com/u/1484001?v=3","gravatar_id":"","url":"https://api.github.com/users/interlegis","html_url":"https://github.com/interlegis","followers_url":"https://api.github.com/users/interlegis/followers","following_url":"https://api.github.com/users/interlegis/following{/other_user}","gists_url":"https://api.github.com/users/interlegis/gists{/gist_id}","starred_url":"https://api.github.com/users/interlegis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/interlegis/subscriptions","organizations_url":"https://api.github.com/users/interlegis/orgs","repos_url":"https://api.github.com/users/interlegis/repos","events_url":"https://api.github.com/users/interlegis/events{/privacy}","received_events_url":"https://api.github.com/users/interlegis/received_events","type":"Organization","site_admin":false},"repo":{"id":38117210,"name":"sapl","full_name":"interlegis/sapl","owner":{"login":"interlegis","id":1484001,"avatar_url":"https://avatars.githubusercontent.com/u/1484001?v=3","gravatar_id":"","url":"https://api.github.com/users/interlegis","html_url":"https://github.com/interlegis","followers_url":"https://api.github.com/users/interlegis/followers","following_url":"https://api.github.com/users/interlegis/following{/other_user}","gists_url":"https://api.github.com/users/interlegis/gists{/gist_id}","starred_url":"https://api.github.com/users/interlegis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/interlegis/subscriptions","organizations_url":"https://api.github.com/users/interlegis/orgs","repos_url":"https://api.github.com/users/interlegis/repos","events_url":"https://api.github.com/users/interlegis/events{/privacy}","received_events_url":"https://api.github.com/users/interlegis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/interlegis/sapl","description":"Sistema de Apoio ao Processo Legislativo","fork":false,"url":"https://api.github.com/repos/interlegis/sapl","forks_url":"https://api.github.com/repos/interlegis/sapl/forks","keys_url":"https://api.github.com/repos/interlegis/sapl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/interlegis/sapl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/interlegis/sapl/teams","hooks_url":"https://api.github.com/repos/interlegis/sapl/hooks","issue_events_url":"https://api.github.com/repos/interlegis/sapl/issues/events{/number}","events_url":"https://api.github.com/repos/interlegis/sapl/events","assignees_url":"https://api.github.com/repos/interlegis/sapl/assignees{/user}","branches_url":"https://api.github.com/repos/interlegis/sapl/branches{/branch}","tags_url":"https://api.github.com/repos/interlegis/sapl/tags","blobs_url":"https://api.github.com/repos/interlegis/sapl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/interlegis/sapl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/interlegis/sapl/git/refs{/sha}","trees_url":"https://api.github.com/repos/interlegis/sapl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/interlegis/sapl/statuses/{sha}","languages_url":"https://api.github.com/repos/interlegis/sapl/languages","stargazers_url":"https://api.github.com/repos/interlegis/sapl/stargazers","contributors_url":"https://api.github.com/repos/interlegis/sapl/contributors","subscribers_url":"https://api.github.com/repos/interlegis/sapl/subscribers","subscription_url":"https://api.github.com/repos/interlegis/sapl/subscription","commits_url":"https://api.github.com/repos/interlegis/sapl/commits{/sha}","git_commits_url":"https://api.github.com/repos/interlegis/sapl/git/commits{/sha}","comments_url":"https://api.github.com/repos/interlegis/sapl/comments{/number}","issue_comment_url":"https://api.github.com/repos/interlegis/sapl/issues/comments{/number}","contents_url":"https://api.github.com/repos/interlegis/sapl/contents/{+path}","compare_url":"https://api.github.com/repos/interlegis/sapl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/interlegis/sapl/merges","archive_url":"https://api.github.com/repos/interlegis/sapl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/interlegis/sapl/downloads","issues_url":"https://api.github.com/repos/interlegis/sapl/issues{/number}","pulls_url":"https://api.github.com/repos/interlegis/sapl/pulls{/number}","milestones_url":"https://api.github.com/repos/interlegis/sapl/milestones{/number}","notifications_url":"https://api.github.com/repos/interlegis/sapl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/interlegis/sapl/labels{/name}","releases_url":"https://api.github.com/repos/interlegis/sapl/releases{/id}","deployments_url":"https://api.github.com/repos/interlegis/sapl/deployments","created_at":"2015-06-26T15:01:58Z","updated_at":"2016-01-11T12:20:39Z","pushed_at":"2016-04-25T15:31:04Z","git_url":"git://github.com/interlegis/sapl.git","ssh_url":"git@github.com:interlegis/sapl.git","clone_url":"https://github.com/interlegis/sapl.git","svn_url":"https://github.com/interlegis/sapl","homepage":null,"size":3979,"stargazers_count":8,"watchers_count":8,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":93,"forks":4,"open_issues":93,"watchers":8,"default_branch":"master"}},"base":{"label":"interlegis:master","ref":"master","sha":"656fccba85c45d15aa98cdc50f1a1d1d4173e63a","user":{"login":"interlegis","id":1484001,"avatar_url":"https://avatars.githubusercontent.com/u/1484001?v=3","gravatar_id":"","url":"https://api.github.com/users/interlegis","html_url":"https://github.com/interlegis","followers_url":"https://api.github.com/users/interlegis/followers","following_url":"https://api.github.com/users/interlegis/following{/other_user}","gists_url":"https://api.github.com/users/interlegis/gists{/gist_id}","starred_url":"https://api.github.com/users/interlegis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/interlegis/subscriptions","organizations_url":"https://api.github.com/users/interlegis/orgs","repos_url":"https://api.github.com/users/interlegis/repos","events_url":"https://api.github.com/users/interlegis/events{/privacy}","received_events_url":"https://api.github.com/users/interlegis/received_events","type":"Organization","site_admin":false},"repo":{"id":38117210,"name":"sapl","full_name":"interlegis/sapl","owner":{"login":"interlegis","id":1484001,"avatar_url":"https://avatars.githubusercontent.com/u/1484001?v=3","gravatar_id":"","url":"https://api.github.com/users/interlegis","html_url":"https://github.com/interlegis","followers_url":"https://api.github.com/users/interlegis/followers","following_url":"https://api.github.com/users/interlegis/following{/other_user}","gists_url":"https://api.github.com/users/interlegis/gists{/gist_id}","starred_url":"https://api.github.com/users/interlegis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/interlegis/subscriptions","organizations_url":"https://api.github.com/users/interlegis/orgs","repos_url":"https://api.github.com/users/interlegis/repos","events_url":"https://api.github.com/users/interlegis/events{/privacy}","received_events_url":"https://api.github.com/users/interlegis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/interlegis/sapl","description":"Sistema de Apoio ao Processo Legislativo","fork":false,"url":"https://api.github.com/repos/interlegis/sapl","forks_url":"https://api.github.com/repos/interlegis/sapl/forks","keys_url":"https://api.github.com/repos/interlegis/sapl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/interlegis/sapl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/interlegis/sapl/teams","hooks_url":"https://api.github.com/repos/interlegis/sapl/hooks","issue_events_url":"https://api.github.com/repos/interlegis/sapl/issues/events{/number}","events_url":"https://api.github.com/repos/interlegis/sapl/events","assignees_url":"https://api.github.com/repos/interlegis/sapl/assignees{/user}","branches_url":"https://api.github.com/repos/interlegis/sapl/branches{/branch}","tags_url":"https://api.github.com/repos/interlegis/sapl/tags","blobs_url":"https://api.github.com/repos/interlegis/sapl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/interlegis/sapl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/interlegis/sapl/git/refs{/sha}","trees_url":"https://api.github.com/repos/interlegis/sapl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/interlegis/sapl/statuses/{sha}","languages_url":"https://api.github.com/repos/interlegis/sapl/languages","stargazers_url":"https://api.github.com/repos/interlegis/sapl/stargazers","contributors_url":"https://api.github.com/repos/interlegis/sapl/contributors","subscribers_url":"https://api.github.com/repos/interlegis/sapl/subscribers","subscription_url":"https://api.github.com/repos/interlegis/sapl/subscription","commits_url":"https://api.github.com/repos/interlegis/sapl/commits{/sha}","git_commits_url":"https://api.github.com/repos/interlegis/sapl/git/commits{/sha}","comments_url":"https://api.github.com/repos/interlegis/sapl/comments{/number}","issue_comment_url":"https://api.github.com/repos/interlegis/sapl/issues/comments{/number}","contents_url":"https://api.github.com/repos/interlegis/sapl/contents/{+path}","compare_url":"https://api.github.com/repos/interlegis/sapl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/interlegis/sapl/merges","archive_url":"https://api.github.com/repos/interlegis/sapl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/interlegis/sapl/downloads","issues_url":"https://api.github.com/repos/interlegis/sapl/issues{/number}","pulls_url":"https://api.github.com/repos/interlegis/sapl/pulls{/number}","milestones_url":"https://api.github.com/repos/interlegis/sapl/milestones{/number}","notifications_url":"https://api.github.com/repos/interlegis/sapl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/interlegis/sapl/labels{/name}","releases_url":"https://api.github.com/repos/interlegis/sapl/releases{/id}","deployments_url":"https://api.github.com/repos/interlegis/sapl/deployments","created_at":"2015-06-26T15:01:58Z","updated_at":"2016-01-11T12:20:39Z","pushed_at":"2016-04-25T15:31:04Z","git_url":"git://github.com/interlegis/sapl.git","ssh_url":"git@github.com:interlegis/sapl.git","clone_url":"https://github.com/interlegis/sapl.git","svn_url":"https://github.com/interlegis/sapl","homepage":null,"size":3979,"stargazers_count":8,"watchers_count":8,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":93,"forks":4,"open_issues":93,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/interlegis/sapl/pulls/328"},"html":{"href":"https://github.com/interlegis/sapl/pull/328"},"issue":{"href":"https://api.github.com/repos/interlegis/sapl/issues/328"},"comments":{"href":"https://api.github.com/repos/interlegis/sapl/issues/328/comments"},"review_comments":{"href":"https://api.github.com/repos/interlegis/sapl/pulls/328/comments"},"review_comment":{"href":"https://api.github.com/repos/interlegis/sapl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/interlegis/sapl/pulls/328/commits"},"statuses":{"href":"https://api.github.com/repos/interlegis/sapl/statuses/45379a8eb078c62449df299a7c0d88f590c92ce8"}}}}