Add a trailing slash to URL when updating or deleting a file (tests fixed) (#931)

* Add a trailing slash to URL when updating or deleting a file.

* Update test files to match new create/update/delete_file Repo methods

* Add trailing slash to get_contents() method

* update tests

* add missing slash in get_dir_contents

* add example usage

* remove dup slashes in tests

* clarify example comments
This commit is contained in:
AetherDeity
2018-10-17 08:21:17 +08:00
committed by Wan Liuyang
parent 9d2129c7b9
commit ee9f098d91
6 changed files with 112 additions and 23 deletions
+6 -6
View File
@@ -513,20 +513,20 @@ class Repository(Framework.TestCase):
def testGetContents(self):
self.assertEqual(len(self.repo.get_readme().content), 10212)
self.assertEqual(len(self.repo.get_contents("/doc/ReferenceOfClasses.md").content), 38121)
self.assertEqual(len(self.repo.get_contents("doc/ReferenceOfClasses.md").content), 38121)
def testGetContentDir(self):
contents = self.repo.get_contents("/")
contents = self.repo.get_contents("")
self.assertTrue(isinstance(contents, list))
self.assertEquals(len(contents), 14)
def testGetContentsWithRef(self):
self.assertEqual(len(self.repo.get_readme(ref="refs/heads/topic/ExperimentOnDocumentation").content), 6747)
self.assertEqual(len(self.repo.get_contents("/doc/ReferenceOfClasses.md", ref="refs/heads/topic/ExperimentOnDocumentation").content), 43929)
self.assertEqual(len(self.repo.get_contents("doc/ReferenceOfClasses.md", ref="refs/heads/topic/ExperimentOnDocumentation").content), 43929)
def testCreateFile(self):
newFile = '/doc/testCreateUpdateDeleteFile.md'
newFile = 'doc/testCreateUpdateDeleteFile.md'
content = 'Hello world'
self.repo.create_file(
path=newFile, message='Create file for testCreateFile', content=content,
@@ -534,7 +534,7 @@ class Repository(Framework.TestCase):
author=github.InputGitAuthor("Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00"))
def testUpdateFile(self):
updateFile = '/doc/testCreateUpdateDeleteFile.md'
updateFile = 'doc/testCreateUpdateDeleteFile.md'
content = 'Hello World'
sha = self.repo.get_contents(updateFile).sha
self.repo.update_file(
@@ -543,7 +543,7 @@ class Repository(Framework.TestCase):
author=github.InputGitAuthor("Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00"))
def testDeleteFile(self):
deleteFile = '/doc/testCreateUpdateDeleteFile.md'
deleteFile = 'doc/testCreateUpdateDeleteFile.md'
sha = self.repo.get_contents(deleteFile).sha
self.repo.delete_file(path=deleteFile, message='Delete file for testDeleteFile', sha=sha, branch="master")