class VersionControlWrapper:

    def __init__(self, working_directory, vc_type):
        self.working_directory = working_directory
        if vc_type == SVN_TYPE:
            self.implements = SVNVersionControl(working_directory)
        elif vc_type == GIT_TYPE:
            self.implements = GitVersionControl(working_directory)

    def info(self, path):
        # return some information on the repository
        self.implements.info(path)

    def add(self, path):
        # add file to repository
        self.implements.add(path)

    def commit(self, commit_comment="Default Comment - Changed File"):
        # commit changes to repository
        # SVN (and possibly GIT) requires a comment for each commit.
        self.implements.commit(self.working_directory, commit_comment)

    def update(self, update_path):
        # update local file from repository
        self.implements.update(update_path)

    def remove(self, path):
        self.implements.remove(path)
    def test_WHEN_config_name_does_not_contain_rcptt_THEN_add(self):
        mock_vc = Mock()
        cfg = GitVersionControl(None, mock_vc)
        cfg.add("test")

        calls = mock_vc.method_calls

        self.assertEqual(len(calls), 1)
        self.assertTrue("test" == calls[0][1][0][0])
 def __init__(self, working_directory, vc_type):
     self.working_directory = working_directory
     if vc_type == SVN_TYPE:
         self.implements = SVNVersionControl(working_directory)
     elif vc_type == GIT_TYPE:
         self.implements = GitVersionControl(working_directory)
 def test_WHEN_banch_begins_contains_nd_THEN_branch_allowed(self):
     self.assertTrue(GitVersionControl.branch_allowed("testNDtest"))
 def test_WHEN_banch_begins_with_nd_THEN_branch_not_allowed(self):
     self.assertFalse(GitVersionControl.branch_allowed("NDTEST"))
 def test_WHEN_banch_is_machine_name_THEN_branch_allowed(self):
     self.assertTrue(GitVersionControl.branch_allowed(socket.gethostname()))
 def test_WHEN_banch_is_master_THEN_branch_not_allowed(self):
     self.assertFalse(GitVersionControl.branch_allowed("master"))
    def test_WHEN_config_name_contains_rcptt_THEN_do_not_add(self):
        mock_vc = Mock()
        cfg = GitVersionControl(None, mock_vc)
        cfg.add(SYSTEM_TEST_PREFIX + "test")

        self.assertEqual(len(mock_vc.method_calls), 0)