From e0b11f4af2c5a33c1ec6ec0e8e30bd71f6d39508 Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:16:50 -0400 Subject: [PATCH 1/8] add requirements --- .gitignore | 2 ++ requirements.txt | 1 + 2 files changed, 3 insertions(+) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 7bbc71c..d98b667 100644 --- a/.gitignore +++ b/.gitignore @@ -99,3 +99,5 @@ ENV/ # mypy .mypy_cache/ + +.idea/* diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7369cb8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests==2.14.2 From cd0166e63b06b26306ccdb40999563c54a6296ab Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:18:14 -0400 Subject: [PATCH 2/8] update gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index d98b667..fdc94aa 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,7 @@ ENV/ .mypy_cache/ .idea/* +*.pyc +.coverage +dist/ +opentable.egg-info \ No newline at end of file From 7c31d0d64519c92e675e165a1f60562558060308 Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:31:19 -0400 Subject: [PATCH 3/8] add basic client methods --- opentable/__init__.py | 0 opentable/client.py | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 opentable/__init__.py create mode 100644 opentable/client.py diff --git a/opentable/__init__.py b/opentable/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/opentable/client.py b/opentable/client.py new file mode 100644 index 0000000..fa58567 --- /dev/null +++ b/opentable/client.py @@ -0,0 +1,20 @@ +import requests + + +class OpenTableClient: + def __init__(self): + self.base_url = "https://opentable.herokuapp.com/api" + + def get_summary_statistics(self): + r = requests.get(url="{base_url}/stats".format(base_url=self.base_url)) + + r.raise_for_status() + + r.json() + + def get_cities(self): + r = requests.get(url="{base_url}/cities".format(base_url=self.base_url)) + + r.raise_for_status() + + r.json() From b364b2e53f458569ff27425a8d724ecddecc5e40 Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:32:00 -0400 Subject: [PATCH 4/8] add coveragerc --- .coveragerc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..9f96edc --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[report] +omit = + */python?.?/* + */site-packages/nose/* + *__init__* \ No newline at end of file From b3c17c7a153d0f3982c9632148d38921e2420971 Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:32:33 -0400 Subject: [PATCH 5/8] add travis --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4f68d83 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: python +python: + - "2.7" +# command to install dependencies +install: "pip install -r requirements.txt" +# command to run tests +script: +- nosetests --with-coverage # Add me to run nose with coverage +after_success: + - coveralls \ No newline at end of file From b05415996be8ebccc315fcaed2229956df32a222 Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:43:58 -0400 Subject: [PATCH 6/8] add integration tests --- opentable/client.py | 18 +++++++++++------- tests/__init__.py | 0 tests/test_openTableClientIntegrationTest.py | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/test_openTableClientIntegrationTest.py diff --git a/opentable/client.py b/opentable/client.py index fa58567..7aabf88 100644 --- a/opentable/client.py +++ b/opentable/client.py @@ -2,19 +2,23 @@ class OpenTableClient: + base_url = "https://opentable.herokuapp.com/api" + def __init__(self): - self.base_url = "https://opentable.herokuapp.com/api" + pass - def get_summary_statistics(self): - r = requests.get(url="{base_url}/stats".format(base_url=self.base_url)) + @staticmethod + def get_summary_statistics(): + r = requests.get(url="{base_url}/stats".format(base_url=OpenTableClient.base_url)) r.raise_for_status() - r.json() + return r.json() - def get_cities(self): - r = requests.get(url="{base_url}/cities".format(base_url=self.base_url)) + @staticmethod + def get_cities(): + r = requests.get(url="{base_url}/cities".format(base_url=OpenTableClient.base_url)) r.raise_for_status() - r.json() + return r.json() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_openTableClientIntegrationTest.py b/tests/test_openTableClientIntegrationTest.py new file mode 100644 index 0000000..f1d9039 --- /dev/null +++ b/tests/test_openTableClientIntegrationTest.py @@ -0,0 +1,20 @@ +from unittest import TestCase + +from opentable.client import OpenTableClient + + +class OpenTableClientIntegrationTest(TestCase): + def test_fetching_summary_statistics(self): + summary_statistics = OpenTableClient.get_summary_statistics() + self.assertIsNotNone(summary_statistics) + self.assertEqual(len(summary_statistics), 3) + self.assertTrue("countries" in summary_statistics) + self.assertTrue("cities" in summary_statistics) + self.assertTrue("restaurants" in summary_statistics) + + def test_fetching_cities(self): + cities = OpenTableClient.get_cities() + self.assertIsNotNone(cities) + self.assertEqual(len(cities), 2) + self.assertTrue("count" in cities) + self.assertTrue("cities" in cities) From 40cd65a2a22751944f56e10adf58fd4edf30302c Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:50:05 -0400 Subject: [PATCH 7/8] update --- .travis.yml | 2 +- requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f68d83..896ab07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,6 @@ python: install: "pip install -r requirements.txt" # command to run tests script: -- nosetests --with-coverage # Add me to run nose with coverage + - nosetests --with-coverage # Add me to run nose with coverage after_success: - coveralls \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7369cb8..caaa432 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ +coverage==4.4.1 requests==2.14.2 From a13eed316327dfc33160eb2c8115cf65fbbb5360 Mon Sep 17 00:00:00 2001 From: jaebradley Date: Mon, 22 May 2017 23:50:13 -0400 Subject: [PATCH 8/8] add coverage requirements --- requirements.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index caaa432..6c1b16b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,5 @@ -coverage==4.4.1 +coverage==4.0.3 +python-coveralls==2.9.1 +PyYAML==3.12 requests==2.14.2 +six==1.10.0