From 5f0e0a0ca25770784c47f1036bf972bd29a14789 Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Thu, 5 Jul 2012 14:26:04 -0400 Subject: renamed test files, added copyright notice --- tests/__init__.py | 27 +++++++++++++++++--- tests/forms.py | 0 tests/models.py | 0 tests/test_forms.py | 20 +++++++++++++++ tests/test_models.py | 20 +++++++++++++++ tests/test_views.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/views.py | 51 ------------------------------------- 7 files changed, 136 insertions(+), 54 deletions(-) delete mode 100644 tests/forms.py delete mode 100644 tests/models.py create mode 100644 tests/test_forms.py create mode 100644 tests/test_models.py create mode 100644 tests/test_views.py delete mode 100644 tests/views.py (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py index ad4f8a1..4cf4941 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,24 @@ -from gsoc.tests.views import * -from gsoc.tests.models import * -from gsoc.tests.forms import * +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of HyperKitty. +# +# HyperKitty is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# HyperKitty is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# HyperKitty. If not, see . +# +# Author: Aamir Khan +# + +from gsoc.tests.test_views import * +from gsoc.tests.test_models import * +from gsoc.tests.test_forms import * diff --git a/tests/forms.py b/tests/forms.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/models.py b/tests/models.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_forms.py b/tests/test_forms.py new file mode 100644 index 0000000..9a056cd --- /dev/null +++ b/tests/test_forms.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of HyperKitty. +# +# HyperKitty is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# HyperKitty is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# HyperKitty. If not, see . +# +# Author: Aamir Khan +# diff --git a/tests/test_models.py b/tests/test_models.py new file mode 100644 index 0000000..9a056cd --- /dev/null +++ b/tests/test_models.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of HyperKitty. +# +# HyperKitty is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# HyperKitty is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# HyperKitty. If not, see . +# +# Author: Aamir Khan +# diff --git a/tests/test_views.py b/tests/test_views.py new file mode 100644 index 0000000..b94ef43 --- /dev/null +++ b/tests/test_views.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of HyperKitty. +# +# HyperKitty is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# HyperKitty is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# HyperKitty. If not, see . +# +# Author: Aamir Khan +# + +from django.test import TestCase +from django.test.client import Client +from django.contrib.auth.models import User +from django.core.urlresolvers import reverse + +class AccountViewsTestCase(TestCase): + + def setUp(self): + self.client = Client() + + def test_login(self): + # Try to access user profile (private data) without logging in + response = self.client.get(reverse('user_profile')) + self.assertRedirects(response, "%s?next=%s" % (reverse('user_login'),reverse('user_profile'))) + + def test_profile(self): + User.objects.create_user('testuser', 'syst3m.w0rm+test@gmail.com', 'testPass') + user = self.client.login(username='testuser', password='testPass') + + response = self.client.get(reverse('user_profile')) + self.assertEqual(response.status_code, 200) + + # Verify that user_profile is present in request context + self.assertTrue('user_profile' in response.context) + + # Verify karma for newly created user is 1 + self.assertEqual(response.context['user_profile'].karma, 1) + + + def test_registration(self): + + User.objects.create_user('testuser', 'syst3m.w0rm+test@gmail.com', 'testPass') + user = self.client.login(username='testuser', password='testPass') + + # If the user if already logged in, redirect to index page..don't let him register again + response = self.client.get(reverse('user_registration')) + self.assertRedirects(response, reverse('index')) + self.client.logout() + + # Access the user registration page after logging out and try to register now + response = self.client.get(reverse('user_registration')) + self.assertEqual(response.status_code, 200) + + # @TODO: Try to register a user and verify its working + + + + + + + \ No newline at end of file diff --git a/tests/views.py b/tests/views.py deleted file mode 100644 index 2ce933a..0000000 --- a/tests/views.py +++ /dev/null @@ -1,51 +0,0 @@ -from django.test import TestCase -from django.test.client import Client -from django.contrib.auth.models import User -from django.core.urlresolvers import reverse - -class AccountViewsTestCase(TestCase): - - def setUp(self): - self.client = Client() - - def test_login(self): - # Try to access user profile (private data) without logging in - response = self.client.get(reverse('user_profile')) - self.assertRedirects(response, "%s?next=%s" % (reverse('user_login'),reverse('user_profile'))) - - def test_profile(self): - User.objects.create_user('testuser', 'syst3m.w0rm+test@gmail.com', 'testPass') - user = self.client.login(username='testuser', password='testPass') - - response = self.client.get(reverse('user_profile')) - self.assertEqual(response.status_code, 200) - - # Verify that user_profile is present in request context - self.assertTrue('user_profile' in response.context) - - # Verify karma for newly created user is 1 - self.assertEqual(response.context['user_profile'].karma, 1) - - - def test_registration(self): - - User.objects.create_user('testuser', 'syst3m.w0rm+test@gmail.com', 'testPass') - user = self.client.login(username='testuser', password='testPass') - - # If the user if already logged in, redirect to index page..don't let him register again - response = self.client.get(reverse('user_registration')) - self.assertRedirects(response, reverse('index')) - self.client.logout() - - # Access the user registration page after logging out and try to register now - response = self.client.get(reverse('user_registration')) - self.assertEqual(response.status_code, 200) - - # @TODO: Try to register a user and verify its working - - - - - - - \ No newline at end of file -- cgit