Author: batiste.bieler
Date: Sat Jul 11 07:24:12 2009
New Revision: 604
Modified:
trunk/example/test_runner.py
trunk/pages/managers.py
trunk/pages/tests/pages_tests.py
Log:
Better test coverage 83%
Modified: trunk/example/test_runner.py
==============================================================================
--- trunk/example/test_runner.py (original)
+++ trunk/example/test_runner.py Sat Jul 11 07:24:12 2009
@@ -19,7 +19,7 @@
mod_list = []
for root, dirs, files in os.walk(app_dirpath):
root_path = app_path +
root[len(app_dirpath):].split(os.path.sep)[1:]
- if not '.svn' in root_path:
+ if not '.svn' in root_path and not 'tests' in root_path:
for file in files:
if file not in exclude_files:
if file.lower().endswith('.py'):
@@ -37,15 +37,15 @@
def run_tests(test_labels, verbosity=1, interactive=True,
extra_tests=[]):
- """cov = coverage()
+ cov = coverage()
cov.erase()
cov.use_cache(0)
cov.start()
- app = get_app('pages')"""
- #modules = get_all_coverage_modules(app,
exclude_files=['auto_render.py'])
+ app = get_app('pages')
+ modules = get_all_coverage_modules(app,
exclude_files=['auto_render.py'])
results = django_test_runner(test_labels, verbosity, interactive,
extra_tests)
- """cov.stop()
- cov.html_report(modules, directory='coverage')"""
+ cov.stop()
+ cov.html_report(modules, directory='coverage')
return results
Modified: trunk/pages/managers.py
==============================================================================
--- trunk/pages/managers.py (original)
+++ trunk/pages/managers.py Sat Jul 11 07:24:12 2009
@@ -35,7 +35,7 @@
"""Return a queryset with pages that don't have parents."""
return self.filter(parent__isnull=True)
- def valid_targets(self, page_id, request, perms, page=None):
+ def valid_targets(self, page_id, perms="All", page=None):
"""QuerySet of valid targets for moving a page into the tree"""
if page is None:
page = self.get(pk=page_id)
Modified: trunk/pages/tests/pages_tests.py
==============================================================================
--- trunk/pages/tests/pages_tests.py (original)
+++ trunk/pages/tests/pages_tests.py Sat Jul 11 07:24:12 2009
@@ -577,3 +577,39 @@
except TemplateDoesNotExist, e:
if e.args != ('404.html',):
raise
+
+ def test_24_page_valid_targets(self):
+ """Test page valid_targets method"""
+ c = Client()
+ c.login(username= 'batiste', password='b')
+ page_data = self.get_new_page_data()
+ page_data['slug'] = 'root'
+ response = c.post('/admin/pages/page/add/', page_data)
+ root_page = Content.objects.get_content_slug_by_slug('root').page
+ page_data['position'] = 'first-child'
+ page_data['target'] = root_page.id
+ page_data['slug'] = 'child-1'
+ response = c.post('/admin/pages/page/add/', page_data)
+ c1 = Content.objects.get_content_slug_by_slug('child-1').page
+
+ self.assertEqual(len(Page.objects.valid_targets(root_page.id)), 0)
+ self.assertEqual(str(Page.objects.valid_targets(c1.id)),
+ "[<Page: root>]")
+
+ def test_25_page_admin_view(self):
+ """Test page admin view"""
+ c = Client()
+ c.login(username= 'batiste', password='b')
+ page_data = self.get_new_page_data()
+ page_data['slug'] = 'page-1'
+ response = c.post('/admin/pages/page/add/', page_data)
+ page = Content.objects.get_content_slug_by_slug('page-1').page
+ self.assertEqual(page.status, 1)
+ response = c.post('/admin/pages/page/%d/change-status-draft/' %
+ page.id)
+ page = Content.objects.get_content_slug_by_slug('page-1').page
+ self.assertEqual(page.status, 0)
+
+ url = '/admin/pages/page/%d/modify-content/title/en-us/' % page.id
+ response = c.post(url, {'content': 'test content'})
+ self.assertEqual(page.title(), 'test content')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---