Changeset 1593
- Timestamp:
- 05/26/08 16:35:14 (22 months ago)
- Location:
- trunk/pylucid/tests
- Files:
-
- 5 added
- 1 modified
-
test_plugin_api.py (added)
-
unittest_plugin (added)
-
unittest_plugin/unittest_plugin.py (added)
-
unittest_plugin/unittest_plugin_cfg.py (added)
-
unittest_plugin/__init__.py (added)
-
__init__.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/tests/__init__.py
r1592 r1593 89 89 """ 90 90 91 import sys92 91 import os 93 92 import re 93 import sys 94 import pprint 95 import shutil 94 96 import tempfile 95 97 import unittest 96 import pprint97 98 98 from StringIO import StringIO 99 99 … … 104 104 105 105 from django.conf import settings 106 from PyLucid.install.install import DB_DumpFakeOptions 106 107 from django.contrib.auth.models import User, UNUSABLE_PASSWORD 108 from django.test import TestCase as DjangoTestCase 109 110 from tests.utils.BrowserDebug import debug_response 111 107 112 from PyLucid.tools.db_dump import loaddb 108 113 from PyLucid.tools.Diff import make_diff 109 from tests.utils.BrowserDebug import debug_response 110 114 from PyLucid.install.install import DB_DumpFakeOptions 111 115 from PyLucid.models import Page, Style, Template, Plugin 112 from django.contrib.auth.models import User, UNUSABLE_PASSWORD113 from django.test import TestCase as DjangoTestCase 116 from PyLucid.system.plugin_manager import auto_install_plugins, install_plugin 117 114 118 115 119 # Display invalid (e.g. misspelled, unused) template variables … … 183 187 FIXTURE_FILE = tempfile.NamedTemporaryFile(prefix='PyLucid_',suffix='.json') 184 188 189 # unittest plugin paths 190 # (relative path here! Because the current work dir can chaned!) 191 TEST_PLUGIN_SRC = "tests/unittest_plugin/" 192 TEST_PLUGIN_DST = "PyLucid/plugins_external/unittest_plugin" 193 194 185 195 def change_preferences(plugin_name, **kwargs): 186 196 """ … … 416 426 """ 417 427 print "Installing PyLucid internal plugins ", 418 from PyLucid.system.plugin_manager import auto_install_plugins419 420 428 auto_install_plugins(debug=True, extra_verbose=extra_verbose) 421 429 print "" 430 431 432 433 def init_unittest_plugin(): 434 """ 435 initialize the unittest plugin 436 -copy ./tests/unittest_plugin/ into ./PyLucid/plugins_external/ 437 -install+activate the plugin into the database 438 """ 439 print "initialize the unittest plugin" 440 print "copy %s to %s" % (TEST_PLUGIN_SRC, TEST_PLUGIN_DST) 441 try: 442 shutil.copytree( 443 os.path.abspath(TEST_PLUGIN_SRC), os.path.abspath(TEST_PLUGIN_DST) 444 ) 445 except OSError, err: 446 import errno 447 if err.errno == errno.EEXIST: # [Errno 17] File exists 448 # A prior unittest run aborted? 449 print "Info:", err 450 else: 451 print "os.getcwd():", os.getcwd() 452 raise 453 454 install_plugin( 455 package_name = "PyLucid.plugins_external", 456 plugin_name = "unittest_plugin", 457 debug = True, 458 active=True, 459 extra_verbose=True, 460 ) 461 462 463 def remove_unittest_plugin(): 464 print "remove unittest plugin (%s)" % TEST_PLUGIN_DST 465 shutil.rmtree(os.path.abspath(TEST_PLUGIN_DST)) 466 422 467 423 468 def create_user(username, password, email, is_staff, is_superuser): … … 472 517 473 518 474 def create_page( data):475 """ 476 Creates Page object with given data.519 def create_page(**kwargs): 520 """ 521 Creates Page object with given kwargs. 477 522 """ 478 523 default_user = User.objects.get( … … 484 529 485 530 page = Page( 486 name = data.get("name", "New Page"),487 shortcut = data.get("shortcut", None),488 content = data.get("content", "TestPageContent"),489 template = data.get("template", default_template),490 style = data.get("style", default_style),491 markup = data.get("markup", default_markup),492 createby = data.get("user", default_user),493 lastupdateby = data.get("user", default_user),494 showlinks = data.get("showlinks", True),495 permitViewPublic = data.get("permitViewPublic", True),496 permitViewGroup = data.get("permitViewGroup", None),497 permitEditGroup = data.get("permitEditGroup", None),498 parent = data.get("parent", None),531 name = kwargs.get("name", "New Page"), 532 shortcut = kwargs.get("shortcut", None), 533 content = kwargs.get("content", "TestPageContent"), 534 template = kwargs.get("template", default_template), 535 style = kwargs.get("style", default_style), 536 markup = kwargs.get("markup", default_markup), 537 createby = kwargs.get("user", default_user), 538 lastupdateby = kwargs.get("user", default_user), 539 showlinks = kwargs.get("showlinks", True), 540 permitViewPublic = kwargs.get("permitViewPublic", True), 541 permitViewGroup = kwargs.get("permitViewGroup", None), 542 permitEditGroup = kwargs.get("permitEditGroup", None), 543 parent = kwargs.get("parent", None), 499 544 ) 500 545 page.save() … … 509 554 page_data.update(kwargs) 510 555 page_data["parent"] = parent 511 last_page = create_page( page_data)556 last_page = create_page(**page_data) 512 557 if "subitems" in page_data: 513 558 create_pages( … … 530 575 create_users() # Create all test users 531 576 create_pages(TEST_PAGES) # Create the test pages 577 init_unittest_plugin() 532 578 create_test_fixture(verbosity) 579 580 def teardown_pylucid(): 581 """ 582 cleanup 583 """ 584 remove_unittest_plugin() 533 585 534 586 def _import_test(module_name,class_name=None): … … 626 678 destroy_test_db(old_name, verbosity) 627 679 teardown_test_environment() 680 teardown_pylucid() 628 681 629 682 return len(result.failures) + len(result.errors)