view tests/test_push_dirs.py @ 676:2a9c009790ce

svnwrap: add subvertpy wrapper Subvertpy is, in many ways, a better interface to Subversion than the SWIG bindings. It's faster, leaks less and offers a cleaner API. The added wrapper is able to coexist with the SWIG wrapper, and not enabled by default. In order to allow this, the wrapper adapts the output from Subvertpy so that it is similar to the output from the SWIG bindings. An example of this can be seen in the modules that work with editors: the nested editors offered by Subvertpy had to be flattened to work with our editor code. This change does not activate the Subvertpy wrapper, yet, and thus does not affect any functionality.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 11 Aug 2010 19:57:35 +0200
parents d2ef7220a079
children 04b3f476e2c3
line wrap: on
line source

import test_util

import unittest

class TestPushDirectories(test_util.TestBase):
    def setUp(self):
        test_util.TestBase.setUp(self)
        test_util.load_fixture_and_fetch('emptyrepo.svndump',
                                         self.repo_path,
                                         self.wc_path)

    def test_push_dirs(self):
        changes = [
            # Single file in single directory
            ('d1/a', 'd1/a', 'a\n'),
            # Two files in one directory
            ('d2/a', 'd2/a', 'a\n'),
            ('d2/b', 'd2/b', 'a\n'),
            # Single file in empty directory hierarchy
            ('d31/d32/d33/d34/a', 'd31/d32/d33/d34/a', 'a\n'),
            ('d31/d32/a', 'd31/d32/a', 'a\n'),
            ]
        self.commitchanges(changes)
        self.pushrevisions()
        self.assertEqual(self.svnls('trunk'),
                          ['d1', 'd1/a', 'd2', 'd2/a', 'd2/b', 'd31',
                           'd31/d32', 'd31/d32/a', 'd31/d32/d33',
                           'd31/d32/d33/d34', 'd31/d32/d33/d34/a'])

        # Add one revision with changed files only, no directory addition
        # or deletion.
        changes = [
            ('d1/a', 'd1/a', 'aa\n'),
            ('d2/a', 'd2/a', 'aa\n'),
            ]
        self.commitchanges(changes)
        self.pushrevisions()

        changes = [
            # Remove single file in single directory
            ('d1/a', None, None),
            # Remove one file out of two
            ('d2/a', None, None),
            # Removing this file should remove one empty parent dir too
            ('d31/d32/d33/d34/a', None, None),
            ]
        self.commitchanges(changes)
        self.pushrevisions()
        self.assertEqual(self.svnls('trunk'),
                         ['d2', 'd2/b', 'd31', 'd31/d32', 'd31/d32/a', ])


class TestPushDirsNotAtRoot(test_util.TestBase):
    def test_push_new_dir_project_root_not_repo_root(self):
        test_util.load_fixture_and_fetch('fetch_missing_files_subdir.svndump',
                                         self.repo_path,
                                         self.wc_path,
                                         subdir='foo')
        changes = [('magic_new/a', 'magic_new/a', 'ohai', ),
                   ]
        self.commitchanges(changes)
        self.pushrevisions()
        self.assertEqual(self.svnls('foo/trunk'), ['bar',
                                                   'bar/alpha',
                                                   'bar/beta',
                                                   'bar/delta',
                                                   'bar/gamma',
                                                   'foo',
                                                   'magic_new',
                                                   'magic_new/a'])

    def test_push_new_file_existing_dir_root_not_repo_root(self):
        test_util.load_fixture_and_fetch('empty_dir_in_trunk_not_repo_root.svndump',
                                         self.repo_path,
                                         self.wc_path,
                                         subdir='project')
        changes = [('narf/a', 'narf/a', 'ohai', ),
                   ]
        self.commitchanges(changes)
        self.assertEqual(self.svnls('project/trunk'), ['a',
                                                       'narf',])
        self.pushrevisions()
        self.assertEqual(self.svnls('project/trunk'), ['a',
                                                       'narf',
                                                       'narf/a'])
        changes = [('narf/a', None, None, ),
                   ]
        self.commitchanges(changes)
        self.pushrevisions()
        self.assertEqual(self.svnls('project/trunk'), ['a' ,])


def suite():
    all = [unittest.TestLoader().loadTestsFromTestCase(TestPushDirectories),
          ]
    return unittest.TestSuite(all)