Login | Register
My pages Projects Community openCollabNet

Discussions > Commits > svn commit: r147 - trunk/repoguard: . src/repoguard/core test/repoguard_test/checks test/repoguard_test/core test/repoguard_test/handlers test/repoguard_test/modules

repoguard
Discussion topic

Back to topic list

svn commit: r147 - trunk/repoguard: . src/repoguard/core test/repoguard_test/checks test/repoguard_test/core test/repoguard_test/handlers test/repoguard_test/modules

Author schlauch
Full name Tobias Schlauch
Date 2012-10-31 02:20:59 PDT
Message Author: schlauch
Date: 2012-10-31 02:20:58-0700
New Revision: 147

Modified:
   trunk/repoguard/MANIFEST.in
   trunk/repoguard/src/​repoguard/core/logge​r.py
   trunk/repoguard/test​/repoguard_test/chec​ks/test_mantis.py
   trunk/repoguard/test​/repoguard_test/chec​ks/test_pylint.py
   trunk/repoguard/test​/repoguard_test/core​/test_logger.py
   trunk/repoguard/test​/repoguard_test/core​/test_module.py
   trunk/repoguard/test​/repoguard_test/hand​lers/test_buildbot.p​y
   trunk/repoguard/test​/repoguard_test/hand​lers/test_mantis.py
   trunk/repoguard/test​/repoguard_test/modu​les/test_mantis.py

Log:
Fixes ISSUE #52:
Added tests to distribution.
Made tests for mantis, pylint, and buildbot optionally.
Corrected logger tests: They will fail if the expected output directory does not exist.

Modified: trunk/repoguard/MANIFEST.in
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/MANIFEST.in?​view=diff&pathre​v=147&r1=146​&r2=147
====================​====================​====================​==================
--- trunk/repoguard/MANIFEST.in (original)
+++ trunk/repoguard/MANIFEST.in 2012-10-31 02:20:58-0700
@@ -1,6 +1,5 @@
 include distribute_setup.py
 recursive-include cfg *.conf
-recursive-exclude test/* *.py
 recursive-exclude dev/* *
 prune doc
 graft doc/html

Modified: trunk/repoguard/src/​repoguard/core/logge​r.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/src/repoguar​d/core/logger.py?vie​w=diff&pathrev=1​47&r1=146&r2​=147
====================​====================​====================​==================
--- trunk/repoguard/src/​repoguard/core/logge​r.py (original)
+++ trunk/repoguard/src/​repoguard/core/logge​r.py 2012-10-31 02:20:58-0700
@@ -85,14 +85,15 @@
         if not os.path.exists(outpu​t_dir_path):
             output_dir_path = constants.CONFIG_HOME
         
- log_file_path = os.path.join(output_dir_path, name)
- max_bytes = long(cls._configurat​ion.get("max_bytes",​ "5242880"))
- backup_count = int(cls._configurati​on.get("backup_count​", "3"))
- handler = handlers.RotatingFileHandler(
- log_file_path, encoding="UTF-8", maxBytes=max_bytes, backupCount=backup_count)
- handler.setFormatter​(logging.Formatter(c​ls._MESSAGE_FORMAT))​
- handler.setLevel(log​ging.NOTSET)
- return handler
+ if os.path.exists(outpu​t_dir_path):
+ log_file_path = os.path.join(output_dir_path, name)
+ max_bytes = long(cls._configurat​ion.get("max_bytes",​ "5242880"))
+ backup_count = int(cls._configurati​on.get("backup_count​", "3"))
+ handler = handlers.RotatingFileHandler(
+ log_file_path, encoding="UTF-8", maxBytes=max_bytes, backupCount=backup_count)
+ handler.setFormatter​(logging.Formatter(c​ls._MESSAGE_FORMAT))​
+ handler.setLevel(log​ging.NOTSET)
+ return handler
 
     @classmethod
     def _configure_root_logger(cls):

Modified: trunk/repoguard/test​/repoguard_test/chec​ks/test_mantis.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/checks/test_​mantis.py?view=diff​&pathrev=147&​r1=146&r2=147
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/chec​ks/test_mantis.py (original)
+++ trunk/repoguard/test​/repoguard_test/chec​ks/test_mantis.py 2012-10-31 02:20:58-0700
@@ -15,15 +15,19 @@
 
 
 """
-Testa the Mantis check.
+Tests of the Mantis check.
 """
 
 
 from configobj import ConfigObj
 import mock
+import pytest
 
-from repoguard.checks import mantis
-
+try:
+ from repoguard.checks import mantis
+ _SKIP = False
+except ImportError:
+ _SKIP = True
 
 _CONFIG_DEFAULT = """
 url=http://localhost/man​tis/mc/mantisconnect​.php?wsdl
@@ -36,6 +40,8 @@
 
 class TestMantisCheck(object):
     
+ pytestmark = pytest.mark.skipif("_SKIP")
+
     @classmethod
     def setup_class(cls):
         cls._mantis_module = mock.Mock()

Modified: trunk/repoguard/test​/repoguard_test/chec​ks/test_pylint.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/checks/test_​pylint.py?view=diff​&pathrev=147&​r1=146&r2=147
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/chec​ks/test_pylint.py (original)
+++ trunk/repoguard/test​/repoguard_test/chec​ks/test_pylint.py 2012-10-31 02:20:58-0700
@@ -21,12 +21,19 @@
 
 from configobj import ConfigObj
 import mock
+import pytest
 
-from repoguard.checks import pylint_
+try:
+ from repoguard.checks import pylint_
+ _SKIP = False
+except ImportError:
+ _SKIP = True
 
 
 class TestPyLint(object):
-
+
+ pytestmark = pytest.mark.skipif("_SKIP")
+
     def setup_method(self, _):
         self._transaction = mock.Mock()
         self._transaction.ge​t_files.return_value​ = {"filepath":"A"}

Modified: trunk/repoguard/test​/repoguard_test/core​/test_logger.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/core/test_lo​gger.py?view=diff​&pathrev=147&r1​=146&r2=147
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/core​/test_logger.py (original)
+++ trunk/repoguard/test​/repoguard_test/core​/test_logger.py 2012-10-31 02:20:58-0700
@@ -58,12 +58,13 @@
         logger = self.factory.create()
         assert logger.root.handlers[0].level == logging.ERROR
         assert len(logger.handlers) == 0
- assert len(logger.root.handlers) == 2
+ assert len(logger.root.handlers) >= 1
         
     def test_create_undefined(self):
         logger = self.factory.create("DEFAULT")
         assert logger.root.handlers[0].level == logging.ERROR
- assert logger.root.handlers[1].level == logging.NOTSET
+ if len(logger.root.handlers) == 2:
+ assert logger.root.handlers[1].level == logging.NOTSET
         
     def test_create_defined(self):
         logger = self.factory.create(​"repoguard.core.vali​dator")

Modified: trunk/repoguard/test​/repoguard_test/core​/test_module.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/core/test_mo​dule.py?view=diff​&pathrev=147&r1​=146&r2=147
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/core​/test_module.py (original)
+++ trunk/repoguard/test​/repoguard_test/core​/test_module.py 2012-10-31 02:20:58-0700
@@ -30,7 +30,7 @@
 import mock
 import pytest
 
-from repoguard.checks.pylint_ import PyLint
+from repoguard.checks import log
 from repoguard.core import constants
 from repoguard.core.config import ProjectConfig
 from repoguard.core.module import Module, CheckManager, HandlerManager
@@ -108,7 +108,7 @@
 
     _HANDLER_CONFIG = """
         protocol.include = Log,
- protocol.exclude = PyLint,"""
+ protocol.exclude = AccessRights,"""
         
     def setup_method(self, _):
         self._handler = Handler(None)
@@ -123,7 +123,7 @@
         assert self._handler._singu​larize.called
         
     def test_singularize_che​ck_skipped(self):
- entry = mock.Mock(check="PyLint")
+ entry = mock.Mock(check="AccessRights")
         entry.is_included.return_value = False
         self._handler.singul​arize(self._config, entry, debug=True)
         assert not self._handler._singu​larize.called
@@ -165,7 +165,7 @@
         for check_name in check_names:
             check = mock.Mock()
             check.name = check_name
- check.load.return_value = PyLint
+ check.load.return_value = log.Log
             checks.append(check)
         pkg_resources.iter_entry_points = mock.Mock(return_value=checks)
 
@@ -174,13 +174,13 @@
             assert check in self._buildin_check_names
             
     def test_load(self):
- check = self._cache.load("PyLint")
- assert issubclass(check, PyLint)
+ check = self._cache.load("Log")
+ assert issubclass(check, log.Log)
         
     def test_fetch_success(self):
- check = self._cache.fetch("PyLint", None)
+ check = self._cache.fetch("Log", None)
         check_id = id(check)
- check = self._cache.fetch("PyLint", None)
+ check = self._cache.fetch("Log", None)
         assert check_id == id(check)
         
     def test_fetch_error(self):
@@ -196,7 +196,7 @@
             [[default]]
                 [[[precommit]]]
                 default=delayonerror
- checks=PyLint,
+ checks=Log,
                 success=Console,
                 error=File.default,
                 

Modified: trunk/repoguard/test​/repoguard_test/hand​lers/test_buildbot.p​y
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/handlers/tes​t_buildbot.py?view=d​iff&pathrev=147​&r1=146&r2=14​7
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/hand​lers/test_buildbot.p​y (original)
+++ trunk/repoguard/test​/repoguard_test/hand​lers/test_buildbot.p​y 2012-10-31 02:20:58-0700
@@ -20,12 +20,13 @@
 
 
 from configobj import ConfigObj
+import pytest
 
 try:
     from repoguard.handlers.buildbot import BuildBot
- _DISABLED = False
+ _SKIP = False
 except ImportError:
- _DISABLED = True
+ _SKIP = True
 
 _CONFIG_DEFAULT = """
 url=localhost
@@ -36,7 +37,8 @@
     
     
 class TestBuildBot(object):
- skipped = _DISABLED
+
+ pytestmark = pytest.mark.skipif("_SKIP")
     
     @classmethod
     def setup_class(cls):

Modified: trunk/repoguard/test​/repoguard_test/hand​lers/test_mantis.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/handlers/tes​t_mantis.py?view=dif​f&pathrev=147​&r1=146&r2=147
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/hand​lers/test_mantis.py (original)
+++ trunk/repoguard/test​/repoguard_test/hand​lers/test_mantis.py 2012-10-31 02:20:58-0700
@@ -24,9 +24,14 @@
 
 import configobj
 import mock
+import pytest
 
 from repoguard.core import protocol as protocol_
-from repoguard.handlers import mantis
+try:
+ from repoguard.handlers import mantis
+ _SKIP = False
+except ImportError:
+ _SKIP = True
 
 
 _CONFIG_DEFAULT = """
@@ -47,6 +52,8 @@
 
 class TestMantis(object):
     
+ pytestmark = pytest.mark.skipif("_SKIP")
+
     def setup_method(self, _):
         self._urlopen = mock.Mock(return_val​ue=StringIO("No Revisions Parsed."))
         mantis.urllib2.urlopen = self._urlopen

Modified: trunk/repoguard/test​/repoguard_test/modu​les/test_mantis.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/modules/test​_mantis.py?view=diff​&pathrev=147​&r1=146&r2=147
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/modu​les/test_mantis.py (original)
+++ trunk/repoguard/test​/repoguard_test/modu​les/test_mantis.py 2012-10-31 02:20:58-0700
@@ -24,8 +24,12 @@
 import mock
 import pytest
 
-from repoguard.modules import mantis
-
+try:
+ from repoguard.modules import mantis
+ _SKIP = False
+except ImportError:
+ _SKIP = True
+
 
 _COMMIT_MESSAGE = """
 mantis id 3662
@@ -37,6 +41,8 @@
 
 class TestMantis(object):
     
+ pytestmark = pytest.mark.skipif("_SKIP")
+
     def setup_method(self, _):
         mantis.Client = mock.MagicMock()
         self.mantis = mantis.Mantis(mock.Mock())

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r147 - trunk/repoguard: . src/repoguard/core test/repoguard_test/checks test/repoguard_test/core test/repoguard_test/handlers test/repoguard_test/modules schlauch Tobias Schlauch 2012-10-31 02:20:59 PDT
Messages per page: