mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
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:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user