r50571 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50570‎ | r50571 | r50572 >
Date:23:54, 13 May 2009
Author:kim
Status:deferred
Tags:
Comment:
Add test_system.py
Modified paths:
  • /trunk/testing/installer/test_system.py (added) (history)

Diff [purge]

Index: trunk/testing/installer/test_system.py
@@ -0,0 +1,99 @@
 2+# This software, copyright (C) 2008-2009 by Wikiation.
 3+# This software is developed by Kim Bruning.
 4+#
 5+# Distributed under the terms of the MIT license.
 6+
 7+import settings_handler as settings
 8+import os, os.path, shutil
 9+import subprocess
 10+from tags import Tags
 11+
 12+try:
 13+ import wiki_works
 14+except:
 15+ pass # we'll deal with this later (in __init__).
 16+ # this allows us to import the module, even
 17+ #though the class can't work (yet)
 18+
 19+
 20+class Test_Exception(Exception):
 21+ pass
 22+
 23+class Test_System(object):
 24+ """An Abstract Test System. Don't instantiate this class directly.
 25+ An installation system understands how to install and uninstall
 26+ 'things' (instances). An instance might be a particular wiki
 27+ (in the case of the mediawiki installer) or a particular extension
 28+ in that wiki (extension installer), or perhaps a tool from the
 29+ toolkit.
 30+ Next to installing and uninstalling, an installer can also determine
 31+ the status of an instance (installed or uninstalled), and can provide
 32+ lists of instances that are available or installed"""
 33+ system_name=None
 34+ destination_dir=None
 35+
 36+ def __init__(self,target=None):
 37+ if "wiki_works" not in globals():
 38+ raise Test_Exception("You need to install pywikipedia and the extension-tester before you can run tests. You can find these fine tools under toolkit:")
 39+ self.testfilesdir=settings.testfilesdir
 40+ self.destination_dir=None
 41+ self.target=target
 42+ self.as_alias=None
 43+ self.revision=None
 44+ self.tag=None
 45+ if instance:
 46+ self.set_instance(instance)
 47+
 48+ def set_instance(self,instance):
 49+ self.instance=instance
 50+
 51+ def get_entities(self):
 52+ """list the extensions we have tests for"""
 53+ entities=os.listdir(self.testfilesdir)
 54+ entities=[]
 55+ for line in entities:
 56+ if line.endswith(".test"):
 57+ entities2.append(line.replace(".test",""))
 58+
 59+ entities2.sort()
 60+ return entities2
 61+
 62+ def tests_for_entity(self, entity):
 63+ # TODO we only have one kind of test right right now.
 64+ return ["WETE"]
 65+
 66+ def entity_exists(self,entity_name):
 67+ """checks to see if a particular installer exists"""
 68+ return entity_name in self.get_entities()
 69+
 70+ def test_exists(self, entity, test):
 71+ if self.entity_exists(entity):
 72+ return test in self.tests_for_extension(extension)
 73+ else:
 74+ return false
 75+
 76+ def testdir_name(self, entity_name):
 77+ """returns the location of the .install directory for the given installer_name.
 78+ An installer directory is where we store all the scripts to install one particular
 79+ extension, tool from the toolkit, or etc. """
 80+ return os.path.join(self.testfilesdir, entity_name+".tests")
 81+
 82+
 83+
 84+ def test (self, entity, test, target=None):
 85+ if not target:
 86+ target=self.target
 87+ if not target:
 88+ raise Test_Exception("What mediawiki instance would you like to test?")
 89+ if test=="WETE":
 90+ self.run_WETE(entity)
 91+ elif test=="wikiworks":
 92+ self.run_wikiworks()
 93+ else:
 94+ raise Test_Exception("I don't know of a test called '"+str(test)+"'.")
 95+
 96+ def run_WETE(self,target,entity):
 97+ pass
 98+
 99+ def run_wikiworks(self,target):
 100+ return wiki_works.wiki_works(target)

Status & tagging log