From 9d2fc3afe3f5fa90c00ad69ea16e537dde5f4b0b Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Thu, 8 Jan 2015 12:03:36 -0200 Subject: [PATCH] Organize test environment, and removed unnessary files. --- README.rst | 1 + colab/accounts/tests/test_request.py | 40 ++++++++++++++++++++++++++++++++++++++++ colab/accounts/tests/tests.py | 56 -------------------------------------------------------- colab/super_archives/fixtures/initial_data.json | 10 ---------- colab/super_archives/tests.py | 16 ---------------- 5 files changed, 41 insertions(+), 82 deletions(-) create mode 100644 colab/accounts/tests/test_request.py delete mode 100644 colab/accounts/tests/tests.py delete mode 100644 colab/super_archives/fixtures/initial_data.json delete mode 100644 colab/super_archives/tests.py diff --git a/README.rst b/README.rst index d2f9b1a..f8f4c82 100644 --- a/README.rst +++ b/README.rst @@ -88,3 +88,4 @@ Follow the steps below: * Go to vagrant/colab/ * run: colab-admin test +* colab-admin collectstatic diff --git a/colab/accounts/tests/test_request.py b/colab/accounts/tests/test_request.py new file mode 100644 index 0000000..3fddedb --- /dev/null +++ b/colab/accounts/tests/test_request.py @@ -0,0 +1,40 @@ +""" +Test account redirections. +Objective: Test requests. +""" + +from django.test import TestCase, Client +from django.test.client import RequestFactory +from django.contrib.messages.storage.fallback import FallbackStorage +from colab.accounts.views import ManageUserSubscriptionsView +from colab.accounts.views import UserProfileDetailView +from colab.accounts.models import User +from django.http.response import Http404 +from colab.accounts.views import signup + +class RequestTest(TestCase): + + def setUp(self): + self.factory = RequestFactory() + self.client = Client() + + def test_successful_signup(self): + # TODO + pass + + def test_invalid_user_profile_url(self): + response = self.client.get('/account/johndoe/') + self.assertEqual(404, response.status_code) + + def test_valid_user_profile_url(self): + self.userTest = User() + self.userTest.username = "usertest" + self.userTest.email = "usertest@colab.com.br" + self.userTest.set_password("1234colab") + self.userTest.save() + response = self.client.get('/account/usertest/') + self.assertEqual(200, response.status_code) + + def test_valid_login_url(self): + response = self.client.get('/account/login') + self.assertEqual(200, response.status_code) diff --git a/colab/accounts/tests/tests.py b/colab/accounts/tests/tests.py deleted file mode 100644 index 878da4a..0000000 --- a/colab/accounts/tests/tests.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - -from django.test import TestCase, Client -from django.test.client import RequestFactory -from django.contrib.messages.storage.fallback import FallbackStorage -from colab.accounts.views import ManageUserSubscriptionsView -from colab.accounts.views import UserProfileDetailView -from colab.accounts.models import User -from django.http.response import Http404 -from colab.accounts.views import signup - -class AccountsTest(TestCase): - - def setUp(self): - self.factory = RequestFactory() - self.client = Client() - - def test_successful_signup(self): - form_data = { - 'first_name': 'John', - 'last_name': 'Doe', - 'email': 'john@doe.com', - 'username': 'johndoe', - } - - post_request = self.factory.post('/account/register/', data=form_data) - - # It makes unittest understant it must add messages - # See: https://code.djangoproject.com/ticket/17971 - setattr(post_request, 'session', 'session') - messages = FallbackStorage(post_request) - setattr(post_request, '_messages', messages) - - response = signup(post_request) - - self.assertEqual('/account/johndoe', response['Location']) - - - def test_invalid_user_profile_url(self): - response = self.client.get('/account/johndoe/') - self.assertEqual(404, response.status_code) - - def test_valid_user_profile_url(self): - self.userTest = User() - self.userTest.username = "usertest" - self.userTest.email = "usertest@colab.com.br" - self.userTest.set_password("1234colab") - self.userTest.save() - response = self.client.get('/account/usertest/') - self.assertEqual(200, response.status_code) - diff --git a/colab/super_archives/fixtures/initial_data.json b/colab/super_archives/fixtures/initial_data.json deleted file mode 100644 index 42c25fb..0000000 --- a/colab/super_archives/fixtures/initial_data.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "pk": 1, - "model": "auth.group", - "fields": { - "name": "developer", - "permissions": [] - } - } -] diff --git a/colab/super_archives/tests.py b/colab/super_archives/tests.py deleted file mode 100644 index 501deb7..0000000 --- a/colab/super_archives/tests.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - -from django.test import TestCase - - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.assertEqual(1 + 1, 2) -- libgit2 0.21.2