commit 5011664c15df2bfe7bdf35c4b408d53411c74312
Author: Francois POIROTTE <francois.poirotte@c-s.fr>
Date:   Mon Aug 31 15:26:49 2009 +0000

    * Migration des tests de vigi(core|board) concernant le modèle dans le dossier idoine.
    
    * Suppression de code mort dans les __init__ des tests de ces 2 composants.
      Le code supprimé était commenté auparavant et consistait à modifier les variables
      d'environnement pour utiliser le module de settings réservé aux tests.
      Cette fonctionnalité est désormais fournie par le Makefile de ces composants.
    
    * Suppression du dossier de modèles spécifiques à vigicore (tous les modèles sont
      partagés avec le reste de Vigilo à présent).
      Vigiboard aura droit au même traitement bientôt.
    
    
    git-svn-id: https://vigilo-dev.si.c-s.fr/svn@622 b22e2e97-25c9-44ff-b637-2e5ceca36478

diff --git a/Makefile b/Makefile
index dcd2ba1..328a42d 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,8 @@ lint: $(PYTHON)
 	$(PYTHON) ./pylint_vigiboard.py $(NAME)
 
 tests: $(PYTHON)
-	PYTHONPATH=$(BUILDENV) $(BUILDENV)/bin/runtests-$(NAME)
+	VIGILO_SETTINGS_MODULE=settings_tests \
+		PYTHONPATH=$(BUILDENV) $(BUILDENV)/bin/runtests-$(NAME)
 
 
 .PHONY: all clean buildclean apidoc lint tests
diff --git a/vigiboard/tests/__init__.py b/vigiboard/tests/__init__.py
index 202f102..41681b7 100644
--- a/vigiboard/tests/__init__.py
+++ b/vigiboard/tests/__init__.py
@@ -66,8 +66,6 @@ class TestController(object):
 
 
 def runtests():
-    # XXX This is a hack, some import gets there first.
-    #environ.setdefault('VIGILO_SETTINGS_MODULE', 'settings_tests')
     # XXX hard-coded path.
     sys.argv[1:0] = ['--with-pylons', '../vigiboard/test.ini', 
                      '--with-coverage', '--cover-inclusive',
diff --git a/vigiboard/tests/models/__init__.py b/vigiboard/tests/models/__init__.py
deleted file mode 100644
index d76510e..0000000
--- a/vigiboard/tests/models/__init__.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Unit test suite for the models of the application."""
-from nose.tools import assert_equals
-
-from vigiboard.model import DBSession
-from vigiboard.tests import setup_db, teardown_db
-
-__all__ = ['ModelTest']
-
-#Create an empty database before we start our tests for this module
-def setup():
-    """Function called by nose on module load"""
-    setup_db()
-    
-#Teardown that database 
-def teardown():
-    """Function called by nose after all tests in this module ran"""
-    teardown_db()
-    
-class ModelTest(object):
-    """Base unit test case for the models."""
-    
-    klass = None
-    attrs = {}
-
-    def setup(self):
-        try:
-            new_attrs = {}
-            new_attrs.update(self.attrs)
-            new_attrs.update(self.do_get_dependencies())
-            self.obj = self.klass(**new_attrs)
-            DBSession.add(self.obj)
-            DBSession.flush()
-            return self.obj
-        except:
-            DBSession.rollback()
-            raise 
-
-    def tearDown(self):
-        DBSession.rollback()
-    
-    def do_get_dependencies(self):
-        """Use this method to pull in other objects that need to be created for this object to be build properly"""
-        return {}
-
-    def test_create_obj(self):
-        pass
-
-    def test_query_obj(self):
-        obj = DBSession.query(self.klass).one()
-        for key, value in self.attrs.iteritems():
-            assert_equals(getattr(obj, key), value)
diff --git a/vigiboard/tests/models/test_auth.py b/vigiboard/tests/models/test_auth.py
deleted file mode 100644
index 196a05b..0000000
--- a/vigiboard/tests/models/test_auth.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Test suite for the TG app's models"""
-from nose.tools import eq_
-
-from vigiboard import model
-from vigiboard.tests.models import ModelTest
-
-class TestGroup(ModelTest):
-    """Unit test case for the ``Group`` model."""
-    klass = model.Group
-    attrs = dict(
-        group_name = u"test_group",
-        display_name = u"Test Group"
-        )
-
-
-class TestUser(ModelTest):
-    """Unit test case for the ``User`` model."""
-    
-    klass = model.User
-    attrs = dict(
-        user_name = u"ignucius",
-        email_address = u"ignucius@example.org"
-        )
-
-    def test_obj_creation_username(self):
-        """The obj constructor must set the user name right"""
-        eq_(self.obj.user_name, u"ignucius")
-
-    def test_obj_creation_email(self):
-        """The obj constructor must set the email right"""
-        eq_(self.obj.email_address, u"ignucius@example.org")
-
-    def test_no_permissions_by_default(self):
-        """User objects should have no permission by default."""
-        eq_(len(self.obj.permissions), 0)
-
-    def test_getting_by_email(self):
-        """Users should be fetcheable by their email addresses"""
-        him = model.User.by_email_address(u"ignucius@example.org")
-        eq_(him, self.obj)
-
-
-class TestPermission(ModelTest):
-    """Unit test case for the ``Permission`` model."""
-    
-    klass = model.Permission
-    attrs = dict(
-        permission_name = u"test_permission",
-        description = u"This is a test Description"
-        )
diff --git a/vigiboard/tests/models/test_vigiboard.py b/vigiboard/tests/models/test_vigiboard.py
deleted file mode 100644
index 32cb7a8..0000000
--- a/vigiboard/tests/models/test_vigiboard.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim:set expandtab tabstop=4 shiftwidth=4:
-"""Test des modèle de Vigiboard"""
-
-from nose.tools import assert_true
-import re
-from vigiboard.model import DBSession, Host, Service, Events, Graph, \
-    GraphGroups, Groups, ServiceHautNiveau, EventHistory, GraphToGroups, \
-    GroupPermissions, HostGroups, PerfDataSource, ServiceGroups, ServiceTopo
-from vigiboard.tests.models import ModelTest
-
-
-class TestEventHistory(ModelTest):
-    """Test de la table EventHistory"""
-
-    klass = EventHistory
-    attrs = dict(type_action = 'Nagios update state', value = '',
-            text = '', username = 'manager')
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Host(name = "monhost"))
-        DBSession.add(Service(name = "monservice"))
-        DBSession.flush()
-        DBSession.add(Events(hostname = "monhost", servicename = "monservice"))
-        DBSession.flush()
-        return dict(idevent = DBSession.query(Events.idevent)[0].idevent)
-
-class TestEvent(ModelTest):
-    """Test de la table Events"""
-
-    klass = Events
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Host(name = "monhost"))
-        DBSession.add(Service(name = "monservice"))
-        DBSession.flush()
-        return dict(hostname = "monhost", servicename = "monservice")
-
-    def test_get_date(self):
-        """La fonction GetDate doit renvoyer un objet formaté"""
-        form1 = re.compile("^\w* \w* \d*:\d*:\d*$")
-        form2 = re.compile("^\w* \d*:\d*:\d*$")
-        assert_true(form1.match(self.obj.get_date("timestamp_active")) \
-                or form2.match(self.obj.get_date("timestamp_active")))
-
-    def test_get_since_date(self):
-        """La fonction GetSinceDate doit renvoyer un objet formaté"""
-        assert_true(re.compile("^\d*d \d*h \d'$").match(
-            self.obj.get_since_date("timestamp_active")))
-        
-class TestGraph(ModelTest):
-    """Test de la table GraphGroups"""
-
-    klass = GraphGroups
-    attrs = dict(name = "mongraph")
-
-class TestGraphToGroups(ModelTest):
-    """Test de la table GraphToGroups"""
-
-    klass = GraphToGroups
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Graph(name = "mongraph"))
-        DBSession.add(GraphGroups(name = "mongraphgroup"))
-        DBSession.flush()
-        return dict(graphname = "mongraph", groupname = "mongraphgroup")
-
-class TestGraphGroups(ModelTest):
-    """Test de la table GraphGroups"""
-
-    klass = GraphGroups
-    attrs = dict(name = "mongraphgroup")
-
-class TestGroupPermissions(ModelTest):
-    """Test de la table GroupPermissions"""
-
-    klass = GroupPermissions
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Groups(name = "mongroup"))
-        DBSession.flush()
-        return dict(groupname = "mongroup")
-
-class TestGroups(ModelTest):
-    """Test de la table Groups"""
-
-    klass = Groups
-    attrs = dict(name = "mongroup")
-
-class TestHost(ModelTest):
-    """Test de la table host"""
-
-    klass = Host
-    attrs = dict(name = "monhost")
-
-class TestHostGroups(ModelTest):
-    """Test de la table hostgroup"""
-
-    klass = HostGroups
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Host(name = "monhost"))
-        DBSession.add(Groups(name = "mongroup"))
-        DBSession.flush()
-        return dict(hostname = "monhost", groupname = "mongroup")
-
-class TestPerfDataSource(ModelTest):
-    """Test de la table perfdatasource"""
-
-    klass = PerfDataSource
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Host(name = "monhost"))
-        DBSession.add(Service(name = "monservice"))
-        DBSession.add(Graph(name = "mongraph"))
-        DBSession.flush()
-        return dict(hostname = "monhost", servicename = "monservice",
-                graphname = "mongraph")
-
-class TestServiceGroups(ModelTest):
-    """Test de la table servicegroups"""
-
-    klass = ServiceGroups
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Service(name = "monservice"))
-        DBSession.add(Groups(name = "mongroupe"))
-        DBSession.flush()
-        return dict(servicename = "monservice", groupname = "mongroupe")
-
-class TestServiceHautNiveau(ModelTest):
-    """Test de la table servicehautniveau"""
-
-    klass = ServiceHautNiveau
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-        
-        DBSession.add(Service(name = "monservice"))
-        DBSession.flush()
-        return dict(servicename = "monservice", servicename_dep = "monservice")
-
-class TestService(ModelTest):
-    """Test de la table service"""
-
-    klass = Service
-    attrs = dict(name = "monservice")
-
-class TestServiceTopo(ModelTest):
-    """Test de la table servicetopo"""
-
-    klass = ServiceTopo
-    attrs = {}
-
-    def do_get_dependencies(self):
-        """Generate some data for the test"""
-
-        DBSession.add(Service(name = "monservice"))
-        DBSession.add(ServiceHautNiveau(servicename = "monservice",
-            servicename_dep = "monservice"))
-        DBSession.flush()
-        return dict(servicename = "monservice")
