def test0302_commit_name(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test', name="Its Me", mail="*****@*****.**") cwd = os.getcwd() os.chdir(local) _, out, _ = command("git log") os.chdir(cwd) self.assertIn("Its Me <*****@*****.**>", out)
def test0501_push_no_url(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') ret, out, err = gitcmd.push(local) self.assertEqual(ret, 0) self.assertIn("master -> master", err)
def test1500_show_last_revision(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') with open(test_file, 'w+') as f: print("Test string", file=f) ret, out, err = gitcmd.show_last_revision(test_file) self.assertEqual(ret, 0) self.assertIn('test', out)
def test0600_branch(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') gitcmd.push(local, HOST_DIR) ret, out, err = gitcmd.branch(local) self.assertEqual(ret, 0) self.assertEqual(out, "* master\n")
def test0403_status_to_commit(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') ret, out, err = gitcmd.status(local) self.assertEqual(ret, 0) self.assertTrue( 'Your branch is ahead of \'origin/master\' by 1 commit.' in out)
def test1005_pull_exception(self): with self.assertRaises(gitcmd.NotInRepositoryError): gitcmd.pull('/tmp', 'url') local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'testfile') test_file2 = os.path.join(local, 'testfile') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local2') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') gitcmd.push(local, HOST_DIR) with self.assertRaises(ValueError): gitcmd.pull(test_file2, HOST_DIR, "username")
def test1001_pull_no_url(self): local = os.path.join(LOCAL_DIRS, 'local') local2 = os.path.join(LOCAL_DIRS, 'local2') test_file = os.path.join(local, 'testfile') test_file2 = os.path.join(local, 'testfile') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local2') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') gitcmd.push(local, HOST_DIR) ret, out, err = gitcmd.pull(local2) self.assertEqual(ret, 0) self.assertIn("Fast-forward\n testfile", out) self.assertTrue(os.path.isfile(test_file2))
def test0300_commit(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') test_file2 = os.path.join(local, 'test2') open(test_file, 'w+').close() gitcmd.add(test_file) ret, out, err = gitcmd.commit(test_file, 'test') self.assertEqual(ret, 0) self.assertTrue( "test\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 test" in out) open(test_file2, 'w+').close() gitcmd.add(test_file2) ret, out, err = gitcmd.commit(local, 'test') self.assertEqual(ret, 0) self.assertTrue( "test\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 test2" in out)
def test0403_status_committed(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') test_file2 = os.path.join(local, 'test2') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') ret, out, err = gitcmd.status(local) self.assertEqual(ret, 0) self.assertIn("Your branch is ahead of 'origin/master' by 1 commit.", out) open(test_file2, 'w+').close() gitcmd.add(test_file2) gitcmd.commit(test_file2, 'test') ret, out, err = gitcmd.status(test_file2) self.assertEqual(ret, 0) self.assertIn("Your branch is ahead of 'origin/master' by 2 commits.", out)
def test0301_commit_exception(self): with self.assertRaises(gitcmd.NotInRepositoryError): gitcmd.commit('/tmp', 'log')
def test0302_commit_mail_noname(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') open(test_file, 'w+').close() with self.assertRaises(ValueError): gitcmd.commit(test_file, 'test', mail="*****@*****.**")
def test0302_commit_name_nomail(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') open(test_file, 'w+').close() with self.assertRaises(ValueError): gitcmd.commit(test_file, 'test', name="Its Me")