def postGitVersion(self): git_module = GitModule(url=self.getRepoURL()) git_module.checkout(self.getGitRef()) data = { "key": self.getPostKey(), "git_ref": "%s / %s" % git_module.getHead() } response = requests.put("%s/sensor/api/device/%s/" % (self.getServerURL(), self.getDeviceID()), data=json.dumps(data))
def postGitVersion(self): try: git_module = GitModule( url = self.getRepoURL() ) git_module.checkout( self.getGitRef( ) ) self.sha = git_module.getHeadSHA() except: pass data = {"key" : self.getPostKey(), "git_ref" : "%s / %s" % (self.getGitRef() , self.sha)} headers = {"Content-Type": "application/json"} response = requests.put("%s/sensor/api/device/%s/" % (self.getServerURL(), self.getDeviceID( )), data = json.dumps( data ) , headers = headers )
def test_create_no_origin(self): origin_repo = make_origin() client_repo = make_client(origin_repo) # Clone from a repository without remote origin - should fail: with self.assertRaises(ValueError): gitm = GitModule(local_path=origin_repo.working_tree_dir)
def testCreate(self): with self.assertRaises(GitCommandError): gitm = GitModule(url="https://does/not/exist") # Must have either url or local_path as arguments. with self.assertRaises(ValueError): gitm = GitModule() # Must have exeactly *one* of url or local_path with self.assertRaises(ValueError): gitm = GitModule(url="https://xxx", local_path="/local") with self.assertRaises(NoSuchPathError): gitm = GitModule(local_path="/tmp/does/not/exist") local_path = tempfile.mkdtemp() with self.assertRaises(InvalidGitRepositoryError): gitm = GitModule(local_path=local_path)
def test_checkout(self): client_repo = make_repo( ) gitm = GitModule( local_path = client_repo.working_tree_dir ) self.assertEqual( gitm.getRoot( ) , client_repo.working_tree_dir) gitm.checkout( "master" ) self.assertEqual( os.path.join( gitm.getRoot( ) , "file.txt" ) , gitm.absPath("file.txt") ) with self.assertRaises( IOError ): file2 = gitm.absPath("file2.txt") gitm.checkout( "version2" ) file2 = gitm.absPath("file2.txt") with self.assertRaises(GitCommandError): gitm.checkout("does-not-exist")
def make_module(): repo = make_repo() return GitModule(local_path=repo.working_tree_dir)
def test_checkout(self): client_repo = make_repo() gitm = GitModule(local_path=client_repo.working_tree_dir) self.assertEqual(gitm.getRoot(), client_repo.working_tree_dir) gitm.checkout("master") self.assertEqual(os.path.join(gitm.getRoot(), "file.txt"), gitm.absPath("file.txt")) self.assertEqual(gitm.getHead()[0], "master") with self.assertRaises(IOError): file2 = gitm.absPath("file2.txt") gitm.checkout("version2") file2 = gitm.absPath("file2.txt") with self.assertRaises(GitCommandError): gitm.checkout("does-not-exist")
def restart(config): git_module = GitModule( url = config.getRepoURL() ) git_module.checkout( config.getGitRef( ) ) git_module.runTests( "tests/run_tests" )