Exemplo n.º 1
0
    class VCSTestCase(unittest.TestCase):
        """
        Test cases for base VCS class (in addition to the Storage test
        cases).
        """

        Class = VCS

        def __init__(self, *args, **kwargs):
            super(VCSTestCase, self).__init__(*args, **kwargs)
            self.dirname = None

        def setUp(self):
            """Set up test fixtures for Storage test case."""
            super(VCSTestCase, self).setUp()
            self.dir = Dir()
            self.dirname = self.dir.path
            self.s = self.Class(repo=self.dirname)
            if self.s.installed() == True:
                self.s.init()
                self.s.connect()

        def tearDown(self):
            super(VCSTestCase, self).tearDown()
            if self.s.installed() == True:
                self.s.disconnect()
                self.s.destroy()
            self.dir.cleanup()
Exemplo n.º 2
0
    class StorageTestCase(unittest.TestCase):
        """Test cases for Storage class."""

        Class = Storage

        def __init__(self, *args, **kwargs):
            super(StorageTestCase, self).__init__(*args, **kwargs)
            self.dirname = None

        # this class will be the basis of tests for several classes,
        # so make sure we print the name of the class we're dealing with.
        def _classname(self):
            version = '?'
            try:
                if hasattr(self, 's'):
                    version = self.s.version()
            except:
                pass
            return '%s:%s' % (self.Class.__name__, version)

        def fail(self, msg=None):
            """Fail immediately, with the given message."""
            raise self.failureException, \
                '(%s) %s' % (self._classname(), msg)

        def failIf(self, expr, msg=None):
            "Fail the test if the expression is true."
            if expr:                raise self.failureException, \
           '(%s) %s' % (self._classname(), msg)

        def failUnless(self, expr, msg=None):
            """Fail the test unless the expression is true."""
            if not expr:                raise self.failureException, \
       '(%s) %s' % (self._classname(), msg)

        def setUp(self):
            """Set up test fixtures for Storage test case."""
            super(StorageTestCase, self).setUp()
            self.dir = Dir()
            self.dirname = self.dir.path
            self.s = self.Class(repo=self.dirname)
            self.assert_failed_connect()
            self.s.init()
            self.s.connect()

        def tearDown(self):
            super(StorageTestCase, self).tearDown()
            self.s.disconnect()
            self.s.destroy()
            self.assert_failed_connect()
            self.dir.cleanup()

        def assert_failed_connect(self):
            try:
                self.s.connect()
                self.fail(
                    "Connected to %(name)s repository before initialising" %
                    vars(self.Class))
            except ConnectionError:
                pass
Exemplo n.º 3
0
Arquivo: base.py Projeto: gitmob/yabbe
    class VCSTestCase (unittest.TestCase):
        """
        Test cases for base VCS class (in addition to the Storage test
        cases).
        """

        Class = VCS

        def __init__(self, *args, **kwargs):
            super(VCSTestCase, self).__init__(*args, **kwargs)
            self.dirname = None

        def setUp(self):
            """Set up test fixtures for Storage test case."""
            super(VCSTestCase, self).setUp()
            self.dir = Dir()
            self.dirname = self.dir.path
            self.s = self.Class(repo=self.dirname)
            if self.s.installed() == True:
                self.s.init()
                self.s.connect()

        def tearDown(self):
            super(VCSTestCase, self).tearDown()
            if self.s.installed() == True:
                self.s.disconnect()
                self.s.destroy()
            self.dir.cleanup()
Exemplo n.º 4
0
    class StorageTestCase (unittest.TestCase):
        """Test cases for Storage class."""

        Class = Storage

        def __init__(self, *args, **kwargs):
            super(StorageTestCase, self).__init__(*args, **kwargs)
            self.dirname = None

        # this class will be the basis of tests for several classes,
        # so make sure we print the name of the class we're dealing with.
        def _classname(self):
            version = '?'
            try:
                if hasattr(self, 's'):
                    version = self.s.version()
            except:
                pass
            return '%s:%s' % (self.Class.__name__, version)

        def fail(self, msg=None):
            """Fail immediately, with the given message."""
            raise self.failureException, \
                '(%s) %s' % (self._classname(), msg)

        def failIf(self, expr, msg=None):
            "Fail the test if the expression is true."
            if expr: raise self.failureException, \
                '(%s) %s' % (self._classname(), msg)

        def failUnless(self, expr, msg=None):
            """Fail the test unless the expression is true."""
            if not expr: raise self.failureException, \
                '(%s) %s' % (self._classname(), msg)

        def setUp(self):
            """Set up test fixtures for Storage test case."""
            super(StorageTestCase, self).setUp()
            self.dir = Dir()
            self.dirname = self.dir.path
            self.s = self.Class(repo=self.dirname)
            self.assert_failed_connect()
            self.s.init()
            self.s.connect()

        def tearDown(self):
            super(StorageTestCase, self).tearDown()
            self.s.disconnect()
            self.s.destroy()
            self.assert_failed_connect()
            self.dir.cleanup()

        def assert_failed_connect(self):
            try:
                self.s.connect()
                self.fail(
                    "Connected to %(name)s repository before initialising"
                    % vars(self.Class))
            except ConnectionError:
                pass