From 14ba3523593bbd2558b8fe2290e49b5ca0edfd07 Mon Sep 17 00:00:00 2001 From: Ryan Matthews Date: Tue, 22 Feb 2022 21:56:41 -0500 Subject: [PATCH] fix: create and update github commands #264 (#291) * Fix create and update github commands #264 - Change get_file_contents to get_contents - Remove beginning '/' on paths * Fix the unit tests --- statuspage/statuspage.py | 6 +++--- statuspage/tests.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/statuspage/statuspage.py b/statuspage/statuspage.py index 888aec9..79136fe 100644 --- a/statuspage/statuspage.py +++ b/statuspage/statuspage.py @@ -144,7 +144,7 @@ def run_upgrade(name, token, org): content = f.read() if template in files: repo_template = repo.get_contents( - path="/" + template, + path=template, ref=head_sha, ) if not is_same_content( @@ -177,7 +177,7 @@ def run_update(name, token, org): # get the template from the repo template_file = repo.get_contents( - path="/template.html", + path="template.html", ref=sha ) @@ -196,7 +196,7 @@ def run_update(name, token, org): try: # get the index.html file, we need the sha to update it index = repo.get_contents( - path="/index.html", + path="index.html", ref=sha, ) diff --git a/statuspage/tests.py b/statuspage/tests.py index 43b6c2e..a28b03d 100644 --- a/statuspage/tests.py +++ b/statuspage/tests.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals import unittest +import traceback from datetime import datetime from unittest import TestCase from mock import patch, Mock @@ -50,8 +51,8 @@ def setUp(self): self.template = Mock() self.template.decoded_content = b"some foo" self.template.content = codecs.encode(b"some other foo", "base64") - self.gh().get_user().get_repo().get_file_contents.return_value = self.template - self.gh().get_organization().get_repo().get_file_contents.return_value = self.template + self.gh().get_user().get_repo().get_contents.return_value = self.template + self.gh().get_organization().get_repo().get_contents.return_value = self.template self.collaborator = Mock() self.collaborator.login = "some-dude"