コード例 #1
0
ファイル: test_builder.py プロジェクト: hagna/simplebb
 def test_findHeads_testPath(self):
     """
     Find heads should find all the heads that match the given testPath
     """
     root = FilePath(self.mktemp())
     
     foo = root.child('foo')
     foo.makedirs()
     test1 = foo.child('test1')
     test2 = foo.child('test2')
     bar = foo.child('bar')
     baz = bar.child('baz')
     
     test1.setContent('test1')
     test2.setContent('test2')
     bar.makedirs()
     baz.setContent('baz')
     
     b = FileBuilder(root)
     
     r = list(b._findHeads('foo', '*'))
     self.assertEqual(len(r), 3, "Should find all the heads with *")
     self.assertEqual(set(r), set([test1, test2, bar]))
     
     r = list(b._findHeads('foo', 'test*'))
     self.assertEqual(len(r), 2)
     self.assertEqual(set(r), set([test1, test2]))
     
     # subdirectory
     r = list(b._findHeads('foo', 'bar/baz'))
     self.assertEqual(r, [baz])
コード例 #2
0
ファイル: test_builder.py プロジェクト: hagna/simplebb
 def test_findHeads_project(self):
     """
     Find heads with only a project given should find a single FilePath
     if it exists
     """
     root = FilePath(self.mktemp())
     root.makedirs()
     b = FileBuilder(root)
     
     # dne
     r = list(b._findHeads('foo'))
     self.assertEqual(r, [], "Should not find paths that don't exist")
     
     # exists
     root.child('foo').setContent('gobbledegook')
     r = list(b._findHeads('foo'))
     self.assertEqual(r, [root.child('foo')])
コード例 #3
0
ファイル: test_builder.py プロジェクト: hagna/simplebb
    def test_findBuilds(self):
        """
        It should call a few functions, passing their results around,
        ending up with FileBuild instances with the correct properties set.
        """
        root = FilePath(self.mktemp())
        # project/
        project = root.child('project')
        project.makedirs()
        
        # project/foo
        foo = project.child('foo')
        # project/bar
        bar = project.child('bar')
        foo.setContent('foo')
        bar.setContent('bar')
        
        b = FileBuilder(root)
        
        class Spy:
            
            def __init__(self, func):
                self.func = func
                self.called = []
            
            def __call__(self, *args):
                self.called.append(args)
                return self.func(*args)


        b._findHeads = Spy(b._findHeads)
        b._getChildFiles = Spy(b._getChildFiles)
        
        r = list(b.findBuilds('project', '*'))
        
        self.assertTrue(b._findHeads.called)
        self.assertTrue(('project', '*') in b._findHeads.called)
        
        self.assertEqual(len(b._getChildFiles.called), 2)
        
        expected = set([
            ('project', 'foo', b, foo),
            ('project', 'bar', b, bar),
        ])
        
        actual = [(x.project, x.test_path, x.builder, x._filepath) for x in r]
        
        self.assertEqual(expected, set(actual))        
        self.assertEqual(len(r), 2)