diff options
author | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-24 17:00:25 -0400 |
---|---|---|
committer | Aamir Khan <syst3m.w0rm@gmail.com> | 2012-07-24 17:00:25 -0400 |
commit | 9f18a590819a01017c15169d82763680a72848fb (patch) | |
tree | 9c781cd677eeae9b1e50e986647e1929e99bdac7 /hyperkitty/tests | |
parent | ae77d9901e2a466622818f95d784fb85b5296727 (diff) | |
download | hyperkitty-9f18a590819a01017c15169d82763680a72848fb.tar.gz hyperkitty-9f18a590819a01017c15169d82763680a72848fb.tar.xz hyperkitty-9f18a590819a01017c15169d82763680a72848fb.zip |
Packaging hyperkitty
Diffstat (limited to 'hyperkitty/tests')
-rw-r--r-- | hyperkitty/tests/__init__.py | 24 | ||||
-rw-r--r-- | hyperkitty/tests/test_forms.py | 20 | ||||
-rw-r--r-- | hyperkitty/tests/test_models.py | 20 | ||||
-rw-r--r-- | hyperkitty/tests/test_views.py | 72 |
4 files changed, 136 insertions, 0 deletions
diff --git a/hyperkitty/tests/__init__.py b/hyperkitty/tests/__init__.py new file mode 100644 index 0000000..4cf4941 --- /dev/null +++ b/hyperkitty/tests/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 <http://www.gnu.org/licenses/>. +# +# Author: Aamir Khan <syst3m.w0rm@gmail.com> +# + +from gsoc.tests.test_views import * +from gsoc.tests.test_models import * +from gsoc.tests.test_forms import * diff --git a/hyperkitty/tests/test_forms.py b/hyperkitty/tests/test_forms.py new file mode 100644 index 0000000..9a056cd --- /dev/null +++ b/hyperkitty/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 <http://www.gnu.org/licenses/>. +# +# Author: Aamir Khan <syst3m.w0rm@gmail.com> +# diff --git a/hyperkitty/tests/test_models.py b/hyperkitty/tests/test_models.py new file mode 100644 index 0000000..9a056cd --- /dev/null +++ b/hyperkitty/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 <http://www.gnu.org/licenses/>. +# +# Author: Aamir Khan <syst3m.w0rm@gmail.com> +# diff --git a/hyperkitty/tests/test_views.py b/hyperkitty/tests/test_views.py new file mode 100644 index 0000000..b94ef43 --- /dev/null +++ b/hyperkitty/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 <http://www.gnu.org/licenses/>. +# +# Author: Aamir Khan <syst3m.w0rm@gmail.com> +# + +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 |