Changeset 937 in tailor


Ignore:
Timestamp:
10/18/05 14:51:50 (8 years ago)
Author:
lele@…
Hash name:
20051018125150-97f81-60b1c4a26928ad7ee5822c3a0f19d39a88de16e8
Message:

Move test configuration in its own external file

Location:
vcpx/tests
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/tests/config.py

    r882 r937  
    1111from vcpx.project import Project 
    1212 
    13 class Config(TestCase): 
     13class Configuration(TestCase): 
    1414    "Test the configuration system" 
    1515 
     
    2929            register(rmtree, '/tmp/tailor-tests') 
    3030 
    31     BASIC_TEST = """\ 
    32 #!tailor 
    33 ''' 
    34 [DEFAULT] 
    35 verbose = False 
    36 target-module = None 
    37 projects = project2 
     31    def getTestConfiguration(self, testname): 
     32        from os.path import join, split 
    3833 
    39 [project1] 
    40 root-directory = /tmp/tailor-tests 
    41 source = svn:project1repo 
    42 target = darcs:project1repo 
    43 refill-changelogs = Yes 
    44 state-file = project1.state 
    45 before-commit = (maybe_skip, refill, p1_remap_authors) 
    46 after-commit = checkpoint 
    47  
    48 [svn:project1repo] 
    49 repository = svn://some.server/svn 
    50 module = project1 
    51 use-propset = Yes 
    52  
    53 [darcs:project1repo] 
    54 repository = ~/darcs/project1 
    55  
    56 [monotone:project1repo] 
    57 repository = /tmp/db 
    58 passphrase = simba 
    59  
    60 [project2] 
    61 root-directory = /tmp/tailor-tests 
    62 source = darcs:project1repo 
    63 target = svn:project2repo 
    64 refill-changelogs = Yes 
    65 state-file = project2.state 
    66 before-commit = refill 
    67  
    68 [svn:project2repo] 
    69  
    70 [project3] 
    71 root-directory = /tmp/tailor-tests 
    72 source = svndump:project3repo 
    73 target = darcs:project3repo 
    74  
    75 [svndump:project3repo] 
    76 repository = %(tailor_repo)s/vcpx/tests/data/simple.svndump 
    77 subdir = plain 
    78  
    79 [darcs:project3repo] 
    80 subdir = . 
    81  
    82 [project4] 
    83 source = svndump:project3repo 
    84 target = darcs:project4repo 
    85  
    86 [darcs:project4repo] 
    87 subdir = darcs 
    88 ''' 
    89  
    90 def maybe_skip(context, changeset): 
    91     for e in changeset.entries: 
    92         if not context.darcs.isBoringFile(e): 
    93             return True 
    94     # What a bunch of boring entries! Skip the patch 
    95     return False 
    96  
    97 def refill(context, changeset): 
    98     changeset.refillChangelog() 
    99     return True 
    100  
    101 p1_authors_map = { 
    102     'lele': 'Lele Gaifax <lele@example.com>', 
    103     'x123': 'A man ... with a name to come', 
    104 } 
    105  
    106 def p1_remap_authors(context, changeset): 
    107     if p1_authors_map.has_key(changeset.author): 
    108         changeset.author = p1_authors_map[changeset.author] 
    109     return True 
    110  
    111 def checkpoint(context, changeset): 
    112     if changeset.log.startswith('Release '): 
    113         context.target.tagWithCheckpoint(changeset.log) 
    114     return True 
    115 """ 
     34        logname = join(split(__file__)[0], 'data', testname)+'.py' 
     35        return file(logname) 
    11636 
    11737    def testBasicConfig(self): 
    118         """Verify the configuration mechanism""" 
     38        """Verify the basic configuration mechanism""" 
    11939 
    120         config = Config(StringIO(self.BASIC_TEST), 
     40        from os import getcwd 
     41 
     42        config = Config(self.getTestConfiguration("config-basic_test"), 
    12143                        {'tailor_repo': self.tailor_repo}) 
     44 
    12245        self.assertEqual(config.projects(), ['project2']) 
     46        self.assertRaises(ConfigurationError, Project, 'project2', config) 
    12347 
    124     def testValidation(self): 
    125         """Verify Repository validation mechanism""" 
     48        project1 = Project('project1', config) 
     49        self.assertEqual(project1.rootdir, '/tmp/tailor-tests') 
    12650 
    127         config = Config(StringIO(self.BASIC_TEST), 
    128                          {'tailor_repo': self.tailor_repo}) 
    129         self.assertRaises(ConfigurationError, Project, 'project2', config) 
     51        project4 = Project('project4', config) 
     52        self.assertEqual(project4.rootdir, getcwd()) 
     53 
     54        self.assert_(config.namespace.has_key('maybe_skip')) 
     55        self.assert_(config.namespace['refill'] in project1.before_commit) 
     56        self.assertEqual(len(project1.after_commit), 1) 
    13057 
    13158    def testSharedDirs(self): 
    13259        """Verify the shared-dir switch""" 
    13360 
    134         config = Config(StringIO(self.BASIC_TEST), 
     61        config = Config(self.getTestConfiguration("config-basic_test"), 
    13562                        {'tailor_repo': self.tailor_repo}) 
    13663 
     
    14673        wd = project4.workingDir() 
    14774        self.assert_(not wd.shared_basedirs) 
    148  
    149     def testRootDirectory(self): 
    150         """Verify the root-directory expansion""" 
    151  
    152         from os import getcwd 
    153  
    154         config = Config(StringIO(self.BASIC_TEST), 
    155                         {'tailor_repo': self.tailor_repo}) 
    156  
    157         project1 = Project('project1', config) 
    158         self.assertEqual(project1.rootdir, '/tmp/tailor-tests') 
    159  
    160         project4 = Project('project4', config) 
    161         self.assertEqual(project4.rootdir, getcwd()) 
Note: See TracChangeset for help on using the changeset viewer.