test/unittest_repositories.py
author David Douard <david.douard@logilab.fr>
Fri, 14 Nov 2014 12:51:47 +0100
changeset 1740 f3137466457a
parent 1677 998cd9f5cbed
permissions -rw-r--r--
Big Refactoring (BR) of the test execution model Get rid of narval preprocessors in favor of Recipes - Each preprocessing recipe must be run from the "main" recipe (thus we add a ATest.exec_recipe() method that can be called from Recipe execution). - We add a (Repository, checkout_recipe, Recipe) relation, which is the Recipe that tells how to retrieve the code for a given Repository - Also add a (ProjectEnvironment, setup_recipe, Recip) dedicated to perform the installation for a project (compile and install) - Add implementations for these recipes for Python project - Rewrite the quick recipe using this new model

#!/usr/bin/python
"""unit tests for apycot.repositories"""

import os
from copy import copy

from logilab.common import testlib

import cubicweb.devtools
from cubes.apycot.testutils import MockVCSFile as VCSFile

from apycotlib.repositories import *

def setUpModule():
    os.environ['APYCOT_ROOT'] = ''

def tearDownModule():
    del os.environ['APYCOT_ROOT']

class GetRepositoryTC(testlib.TestCase):
    def test(self):
        vcsfile = VCSFile('mercurial', source_url='http://www.labas.org')
        repo = get_repository({'repository': vcsfile, 'path': 'toto'})
        self.assert_(isinstance(repo, HGRepository))


class HGRepositoryTC(testlib.TestCase):
    def test_co_path(self):
        vcsfile = VCSFile('mercurial', source_url=u'file://' + os.path.join(self.datadir, 'badsyntax'))
        repo = HGRepository({'repository': vcsfile, 'local_cache': 'common'})
        self.assertEqual(repo.co_path, 'badsyntax/common')
        repo = HGRepository({'repository': vcsfile, 'local_cache': 'common/sub'})
        self.assertEqual(repo.co_path, 'badsyntax/common/sub')

if __name__ == '__main__':
    testlib.unittest_main()