'Exercise branching code of import'

def test_branching(self):

    repo_dir = self.git_repo_dir
    if (not os.path.isdir(repo_dir)):
        os.mkdir(repo_dir)
    self.addCleanup(shutil.rmtree, repo_dir)
    with self.assertRaises(GitImportErrorRemoteBranchMissing):
        git_import.add_repo(self.TEST_REPO, (repo_dir / 'edx4edx_lite'), 'asdfasdfasdf')
    git_import.add_repo(self.TEST_REPO, (repo_dir / 'edx4edx_lite'), self.TEST_BRANCH)
    def_ms = modulestore()
    self.assertIsNotNone(def_ms.get_course(self.TEST_BRANCH_COURSE))
    git_import.add_repo(self.TEST_REPO, (repo_dir / 'edx4edx_lite'), self.TEST_BRANCH)
    def_ms.delete_course(self.TEST_BRANCH_COURSE, ModuleStoreEnum.UserID.test)
    self.assertIsNone(def_ms.get_course(self.TEST_BRANCH_COURSE))
    git_import.add_repo(self.TEST_REPO, (repo_dir / 'edx4edx_lite'), 'master')
    self.assertIsNone(def_ms.get_course(self.TEST_BRANCH_COURSE))
    self.assertIsNotNone(def_ms.get_course(CourseKey.from_string(self.TEST_COURSE)))
