From b274c2e26cc1685a4f2ec50afc17165810a3b0aa Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Sat, 11 Feb 2012 09:31:03 -0500 Subject: [PATCH] Added basic test case --HG-- branch : pmitros-mod-template --- courseware/modules/__init__.py | 11 +++++++++++ courseware/tests.py | 22 +++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/courseware/modules/__init__.py b/courseware/modules/__init__.py index 4150088c22..db8b1abf2d 100644 --- a/courseware/modules/__init__.py +++ b/courseware/modules/__init__.py @@ -34,5 +34,16 @@ for module in modx_module_list: modx_modules[tag] = module.Module def get_module_class(tag): + ''' Given an XML tag (e.g. 'video'), return + the associated module (e.g. video_module.Module). + ''' return modx_modules[tag] +def get_module_id(tag): + ''' Given an XML tag (e.g. 'video'), return + the default ID for that module (e.g. 'youtube_id') + ''' + return modx_modules[tag].id_attribute + +def get_valid_tags(): + return modx_modules.keys() diff --git a/courseware/tests.py b/courseware/tests.py index 501deb776c..03bdbb7ecf 100644 --- a/courseware/tests.py +++ b/courseware/tests.py @@ -1,16 +1,12 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". +import unittest +import courseware.modules -Replace this with more appropriate tests for your application. -""" +class ModelsTest(unittest.TestCase): + def setUp(self): + pass -from django.test import TestCase + def test_get_module_class(self): + vc = courseware.modules.get_module_class('video') + vc_str = "" + self.assertEqual(str(vc), vc_str) - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.assertEqual(1 + 1, 2)