From 282278d19cb32a8beaa2506aaf4a24eca8ec5cee Mon Sep 17 00:00:00 2001 From: Steve Brown Date: Sun, 1 Dec 2013 23:19:58 +0000 Subject: [PATCH] Add initial version of getemojis --- github/MainClass.py | 11 +++++++++++ github/tests/Github_.py | 5 +++++ github/tests/ReplayData/Github.testGetEmojis.txt | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 github/tests/ReplayData/Github.testGetEmojis.txt diff --git a/github/MainClass.py b/github/MainClass.py index e8d73e45..4239ce5a 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -359,6 +359,17 @@ class Github(object): ) return GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes, completed=True) + def get_emojis(self): + """ + :calls: `GET /emojis `_ + :rtype: dictionary of type => url for emoji` + """ + headers, attributes = self.__requester.requestJsonAndCheck( + "GET", + "/emojis" + ) + return attributes + def create_from_raw_data(self, klass, raw_data, headers={}): """ Creates an object from raw_data previously obtained by :attr:`github.GithubObject.GithubObject.raw_data`, diff --git a/github/tests/Github_.py b/github/tests/Github_.py index 57fb2a92..85ff82ae 100644 --- a/github/tests/Github_.py +++ b/github/tests/Github_.py @@ -105,6 +105,11 @@ class Github(Framework.TestCase): self.assertEqual(hook.events, ["push"]) self.assertEqual(hook.schema, [["string", "url"], ["string", "token"], ["string", "project_id"], ["string", "milestone_id"], ["string", "category_id"]]) + def testGetEmojis(self): + emojis = self.g.get_emojis() + first = emojis.get("+1") + self.assertEqual(first, "https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5") + def testGetHook(self): hook = self.g.get_hook("activecollab") self.assertEqual(hook.name, "activecollab") diff --git a/github/tests/ReplayData/Github.testGetEmojis.txt b/github/tests/ReplayData/Github.testGetEmojis.txt new file mode 100644 index 00000000..ceb8ccc0 --- /dev/null +++ b/github/tests/ReplayData/Github.testGetEmojis.txt @@ -0,0 +1,10 @@ +https +GET +api.github.com +None +/emojis +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +null +200 +[('status', '200 OK'), ('content-length', '757'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('x-ratelimit-remaining', '4993'), ('server', 'nginx'), ('connection', 'keep-alive'), ('etag', '"cc8e8df5d003cd489fd90931fa7f751a"'), ('cache-control', 'max-age=0, private, must-revalidate'), ('date', 'Fri, 21 Dec 2012 19:54:21 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"+1": "https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5", "-1": "https://github.global.ssl.fastly.net/images/icons/emoji/-1.png?v5", "100": "https://github.global.ssl.fastly.net/images/icons/emoji/100.png?v5", "1234": "https://github.global.ssl.fastly.net/images/icons/emoji/1234.png?v5", "8ball": "https://github.global.ssl.fastly.net/images/icons/emoji/8ball.png?v5", "a": "https://github.global.ssl.fastly.net/images/icons/emoji/a.png?v5", "ab": "https://github.global.ssl.fastly.net/images/icons/emoji/ab.png?v5"} \ No newline at end of file