[damned-lies] Check system dependencies in test initialization



commit c135c326854a5315be3e752947f132eb3dbc18ce
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Nov 12 09:49:02 2010 +0100

    Check system dependencies in test initialization

 README                  |   16 +++++++++-------
 stats/tests/__init__.py |   10 ++++++++++
 stats/utils.py          |    4 ++++
 3 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/README b/README
index 8568797..a6e80bd 100644
--- a/README
+++ b/README
@@ -17,28 +17,30 @@ Requirements
 
 2 - Python 2.5 (for hashlib module). PIL (python-imaging) for hackergotchi checks.
 
-3 - jQuery (tested with 1.3.1 / 1.4.2) (http://jquery.com) and plugins:
+3 - gettext, intltool, gnome-doc-utils (for stats generation)
+
+4 - jQuery (tested with 1.3.1 / 1.4.2) (http://jquery.com) and plugins:
     * jQuery tablesorter (http://tablesorter.com)
       in /media/js/jquery.tablesorter.min.js
-    * jQuery growfield (http://kuindji.com/jquery/growfield/growfield.xml)
+    * jQuery growfield (http://code.google.com/p/jquery-growfield/)
       in /media/js/jquery.growfield2.js
 
-4 - South >= 0.7 - http://south.aeracode.org/
+5 - South >= 0.7 - http://south.aeracode.org/
     South is a Django extension that allows you to track changes in your models
     over time, and to update the database to reflect those changes.
 
     See http://south.aeracode.org/wiki/Download for installation instructions
 
-5 - Markdown (python-markdown) for Team presentation markup rendering
+6 - Markdown (python-markdown) for Team presentation markup rendering
 
-6 - [Optional] Django Debug Toolbar
+7 - [Optional] Django Debug Toolbar
     git clone git://github.com/dcramer/django-debug-toolbar.git
     Define USE_DEBUG_TOOLBAR to True in settings.py to use it.
 
-7 - [Optional] python-openid and django-openid (see OpenID support
+8 - [Optional] python-openid and django-openid (see OpenID support
     below).
 
-8 - [Optional] python-pyicu for correct sorting in various languages
+9 - [Optional] python-pyicu for correct sorting in various languages
 
 Installation
 ============
diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py
index b1b2dc9..b22f2bc 100644
--- a/stats/tests/__init__.py
+++ b/stats/tests/__init__.py
@@ -25,7 +25,9 @@ from django.test.client import Client
 from django.core import mail
 from django.core.exceptions import ValidationError
 from django.conf import settings
+
 from stats.models import Module, Domain, Branch, Category, Release, Statistics, Information
+from stats.utils import check_program_presence
 from languages.models import Language
 
 def test_scratchdir(test_func):
@@ -39,8 +41,16 @@ def test_scratchdir(test_func):
 
 
 class ModuleTestCase(TestCase):
+    SYS_DEPENDENCIES = (
+        ('gettext', 'msgfmt'),
+        ('intltool', 'intltool-update'),
+        ('gnome-doc-utils', 'xml2po'),
+    )
     def __init__(self, name):
         TestCase.__init__(self, name)
+        for package, prog in self.SYS_DEPENDENCIES:
+            if not check_program_presence(prog):
+                raise Exception("You are missing a required system package needed by Damned Lies (%s)" % package)
         # Delete the checkout if it exists prior to running the test suite
         path = os.path.join(settings.SCRATCHDIR, 'git', 'gnome-hello')
         if os.access(path, os.X_OK):
diff --git a/stats/utils.py b/stats/utils.py
index eec3ee9..7f0faea 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -78,6 +78,10 @@ def run_shell_command(cmd, env=None, input_data=None, raise_on_error=False):
 
     return (status, output, errout)
 
+def check_program_presence(prog_name):
+    """ Test if prog_name is an available command on the system """
+    status, output, err = run_shell_command("which %s" % prog_name)
+    return status == 0
 
 def check_potfiles(po_path):
     """Check if there were any problems regenerating a POT file (intltool-update -m).



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]