Removed cruft from the tests directory
authorSverre Rabbelier <srabbelier@gmail.com>
Wed, 26 Nov 2008 23:55:10 +0000
changeset 593 01f8c7aabb7e
parent 592 be98a2f5d8a2
child 594 06c2228e39cb
Removed cruft from the tests directory The current tests were outdated (they tested code that no longer exists), and were causing the test suite (insofar as it deserves that name) to fail for no reason. Patch by: Sverre Rabbelier
tests/app/soc/__init__.py
tests/app/soc/logic/__init__.py
tests/app/soc/logic/site/__init__.py
tests/app/soc/logic/site/test_page.py
tests/app/soc/views/__init__.py
tests/app/soc/views/simple.py
tests/app/soc/views/test_simple.py
tests/settings_test.py
--- a/tests/app/soc/logic/site/test_page.py	Wed Nov 26 23:54:40 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2008 the Melange authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Unit tests for the Page class and its kin.
-"""
-
-__authors__ = [
-  '"Augie Fackler" <durin42@gmail.com>',
-  ]
-
-import unittest
-
-from django.core import urlresolvers
-from nose import tools
-
-from soc.logic.site import page
-
-class UrlTests(unittest.TestCase):
-  def testSimpleUrl(self):
-    # TODO(durin42) I think this is actually a bug - I gave a callable,
-    # shouldn't this require a name argument to have been provided?
-    url = page.Url(r'/', lambda r: None)
-    tools.eq_(type(url.makeDjangoUrl()), urlresolvers.RegexURLPattern)
-    url = page.Url(r'/', None)
-    tools.eq_(url.makeDjangoUrl(), None)
-
-class PageTests(unittest.TestCase):
-  def setUp(self):
-    self.home_page = page.Page(page.Url('/', lambda r: None, name='Home'),
-                               'Home!', 'Home')
-    self.child_page = page.Page(page.Url('/child', lambda r: None,
-                                         name='Child'),
-                                'Child!', 'Child', parent=self.home_page)
-    self.child_page_2 = page.Page(page.Url('/foo', None, name='None'), 'Bogus',
-                                  'Bogus', parent=self.home_page,
-                                  link_url='/bar')
-
-  def testMenuItems(self):
-    tools.eq_(list(self.home_page.getChildren()), [self.child_page,
-                                                   self.child_page_2,
-                                                  ])
-    menu = self.home_page.makeMenuItem()
-    tools.eq_(menu.name, 'Home')
-    tools.eq_([i.name for i in menu.sub_menu.items], ['Child', 'Bogus', ])
-
-  def testLinkUrl(self):
-    tools.eq_(self.home_page.makeLinkUrl(), '/')
-    tools.eq_(self.child_page.makeLinkUrl(), '/child')
-    tools.eq_(self.child_page_2.makeLinkUrl(), '/bar')
-
-
-if __name__ == '__main__':
-  print 'This is not a standalone script. Please run it using tests/run.py.'
--- a/tests/app/soc/views/simple.py	Wed Nov 26 23:54:40 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#!/usr/bin/env python
-
-
-
-if __name__ == '__main__':
-  print 'This is not a standalone script. Please run it using tests/run.py.'
-
--- a/tests/app/soc/views/test_simple.py	Wed Nov 26 23:54:40 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-from nose import tools
-
-from google.appengine.api import users
-from soc.views import simple
-from soc.logic.site import page
-from soc.views.helper import responses
-from soc.models import user
-
-from tests import test_utils
-
-def mockRespond(request, template, context=None, response_args=None):
-  """Mock implementation of respond that passes variables through.
-  """
-  return request, template, context, response_args
-
-
-orig_respond = responses.respond
-def setup():
-  responses.respond = mockRespond
-
-
-def teardown():
-  responses.respond = orig_respond
-
-
-def test_public_without_user():
-  r = test_utils.MockRequest()
-  inbound_ctx = {'foo': 'bar', }
-  our_page = page.Page(page.Url('/', lambda r: None, name='Home'), 'Home',
-                       'Home')
-  (req, template, context,
-   respond_args, ) = simple.public(r, our_page, context=dict(inbound_ctx),
-                                   link_name='testuser')
-  tools.eq_(req, r)
-  tools.eq_(inbound_ctx['foo'], context['foo'])
-  tools.assert_not_equal(inbound_ctx, context)
-  tools.eq_(context['page'], our_page)
-  tools.eq_(context['error_status'], 404)
-  tools.eq_(context['error_message'], ('There is no user with a "link name" '
-                                       'of "testuser".'))
-
-
-def test_public_with_user():
-  r = test_utils.MockRequest()
-  inbound_ctx = {'foo': 'bar', }
-  our_page = page.Page(page.Url('/', lambda r: None, name='Home'), 'Home',
-                       'Home')
-  u = user.User(link_name='testuser',
-                nick_name='Test User!',
-                id=users.User('foo@bar.com'))
-  u.save()
-  (req, template, context,
-   respond_args, ) = simple.public(r, our_page, context=dict(inbound_ctx),
-                                   link_name='testuser')
-  tools.eq_(req, r)
-  tools.eq_(inbound_ctx['foo'], context['foo'])
-  tools.assert_not_equal(inbound_ctx, context)
-  tools.eq_(context['page'], our_page)
-  assert 'error_status' not in context
-  assert 'error_message' not in context
-  tools.eq_(context['link_name'], 'testuser')
-  tools.eq_(context['link_name_user'].id, u.id)
--- a/tests/settings_test.py	Wed Nov 26 23:54:40 2008 +0000
+++ b/tests/settings_test.py	Wed Nov 26 23:55:10 2008 +0000
@@ -32,7 +32,7 @@
 import sys
 import unittest
 
-from ..scripts import settings
+from scripts import settings
 
 
 class SettingsTests(unittest.TestCase):