How to use add_repo method in avocado

Best Python code snippet using avocado_python

test_git_add_course.py

Source:test_git_add_course.py Github

copy

Full Screen

...88 # Test with all three args (branch)89 call_command('git_add_course', self.TEST_REPO,90 directory_path=self.git_repo_dir / 'edx4edx_lite',91 repository_branch=self.TEST_BRANCH)92 def test_add_repo(self):93 """94 Various exit path tests for test_add_repo95 """96 with self.assertRaises(GitImportErrorNoDir):97 git_import.add_repo(self.TEST_REPO, None, None)98 os.mkdir(self.git_repo_dir)99 self.addCleanup(shutil.rmtree, self.git_repo_dir)100 with self.assertRaises(GitImportErrorUrlBad):101 git_import.add_repo('foo', None, None)102 with self.assertRaises(GitImportErrorCannotPull):103 git_import.add_repo('file:///foobar.git', None, None)104 # Test git repo that exists, but is "broken"105 bare_repo = os.path.abspath('{0}/{1}'.format(settings.TEST_ROOT, 'bare.git'))106 os.mkdir(bare_repo)107 self.addCleanup(shutil.rmtree, bare_repo)108 subprocess.check_output(['git', '--bare', 'init', ], stderr=subprocess.STDOUT,109 cwd=bare_repo)110 with self.assertRaises(GitImportErrorBadRepo):111 git_import.add_repo('file://{0}'.format(bare_repo), None, None)112 def test_detached_repo(self):113 """114 Test repo that is in detached head state.115 """116 repo_dir = self.git_repo_dir117 # Test successful import from command118 try:119 os.mkdir(repo_dir)120 except OSError:121 pass122 self.addCleanup(shutil.rmtree, repo_dir)123 git_import.add_repo(self.TEST_REPO, repo_dir / 'edx4edx_lite', None)124 subprocess.check_output(['git', 'checkout', 'HEAD~2', ],125 stderr=subprocess.STDOUT,126 cwd=repo_dir / 'edx4edx_lite')127 with self.assertRaises(GitImportErrorCannotPull):128 git_import.add_repo(self.TEST_REPO, repo_dir / 'edx4edx_lite', None)129 def test_branching(self):130 """131 Exercise branching code of import132 """133 repo_dir = self.git_repo_dir134 # Test successful import from command135 if not os.path.isdir(repo_dir):136 os.mkdir(repo_dir)137 self.addCleanup(shutil.rmtree, repo_dir)138 # Checkout non existent branch139 with self.assertRaises(GitImportErrorRemoteBranchMissing):140 git_import.add_repo(self.TEST_REPO, repo_dir / 'edx4edx_lite', 'asdfasdfasdf')141 # Checkout new branch142 git_import.add_repo(self.TEST_REPO,143 repo_dir / 'edx4edx_lite',144 self.TEST_BRANCH)145 def_ms = modulestore()146 # Validate that it is different than master147 self.assertIsNotNone(def_ms.get_course(self.TEST_BRANCH_COURSE))148 # Attempt to check out the same branch again to validate branch choosing149 # works150 git_import.add_repo(self.TEST_REPO,151 repo_dir / 'edx4edx_lite',152 self.TEST_BRANCH)153 # Delete to test branching back to master154 def_ms.delete_course(self.TEST_BRANCH_COURSE, ModuleStoreEnum.UserID.test)155 self.assertIsNone(def_ms.get_course(self.TEST_BRANCH_COURSE))156 git_import.add_repo(self.TEST_REPO,157 repo_dir / 'edx4edx_lite',158 'master')159 self.assertIsNone(def_ms.get_course(self.TEST_BRANCH_COURSE))160 self.assertIsNotNone(def_ms.get_course(SlashSeparatedCourseKey.from_deprecated_string(self.TEST_COURSE)))161 def test_branch_exceptions(self):162 """163 This wil create conditions to exercise bad paths in the switch_branch function.164 """165 # create bare repo that we can mess with and attempt an import166 bare_repo = os.path.abspath('{0}/{1}'.format(settings.TEST_ROOT, 'bare.git'))167 os.mkdir(bare_repo)168 self.addCleanup(shutil.rmtree, bare_repo)169 subprocess.check_output(['git', '--bare', 'init', ], stderr=subprocess.STDOUT,170 cwd=bare_repo)171 # Build repo dir172 repo_dir = self.git_repo_dir173 if not os.path.isdir(repo_dir):174 os.mkdir(repo_dir)175 self.addCleanup(shutil.rmtree, repo_dir)176 rdir = '{0}/bare'.format(repo_dir)177 with self.assertRaises(GitImportErrorBadRepo):178 git_import.add_repo('file://{0}'.format(bare_repo), None, None)179 # Get logger for checking strings in logs180 output = StringIO.StringIO()181 test_log_handler = logging.StreamHandler(output)182 test_log_handler.setLevel(logging.DEBUG)183 glog = git_import.log184 glog.addHandler(test_log_handler)185 # Move remote so fetch fails186 shutil.move(bare_repo, '{0}/not_bare.git'.format(settings.TEST_ROOT))187 try:188 git_import.switch_branch('master', rdir)189 except GitImportError:190 self.assertIn('Unable to fetch remote', output.getvalue())191 shutil.move('{0}/not_bare.git'.format(settings.TEST_ROOT), bare_repo)192 output.truncate(0)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful