From cccaa995ae7ffd54b3f74cf07225be7b6117c1e9 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Thu, 19 May 2016 10:53:58 -0400 Subject: [PATCH] add tests --- Makefile | 2 +- celigo/__init__.py | 2 +- celigo/core.py | 18 +++++++++--------- celigo/tests.py | 0 tests.py | 16 ++++++++++++++++ 5 files changed, 27 insertions(+), 11 deletions(-) delete mode 100644 celigo/tests.py create mode 100644 tests.py diff --git a/Makefile b/Makefile index b3806c8..f7bb1cf 100644 --- a/Makefile +++ b/Makefile @@ -2,4 +2,4 @@ init: pip install -r requirements.txt test: - py.test tests + py.test tests.py diff --git a/celigo/__init__.py b/celigo/__init__.py index c535377..f899190 100644 --- a/celigo/__init__.py +++ b/celigo/__init__.py @@ -1 +1 @@ -from .core import BackupCeligo +from core import BackupCeligo diff --git a/celigo/core.py b/celigo/core.py index 4027ed9..a7eb5f8 100644 --- a/celigo/core.py +++ b/celigo/core.py @@ -26,8 +26,15 @@ class BackupCeligo(object): self.base_url = base_url self.imports_cache = {} self.setup_requests_session() - self.ensure_directories_exist() + def setup_requests_session(self): + self.session = requests.Session() + self.session.headers.update({ + "Authorization": "Bearer {API_KEY}".format( + API_KEY=self.api_key), + "Content-Type": "application/json" + }) + def ensure_directories_exist(self): """ Make the directory if it doesn't exist """ subdirs = ('imports', 'connections') @@ -37,14 +44,7 @@ class BackupCeligo(object): if not os.path.exists(_dir): os.makedirs(_dir) - def setup_requests_session(self): - self.session = requests.Session() - self.session.headers.update({ - "Authorization": "Bearer {API_KEY}".format( - API_KEY=self.api_key), - "Content-Type": "application/json" - } - ) + def _celigo_api_get(self, path): """ diff --git a/celigo/tests.py b/celigo/tests.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..0b7176b --- /dev/null +++ b/tests.py @@ -0,0 +1,16 @@ +# testing imports +import pytest + +# package imports +import celigo + +def test_needs_all_params(): + """ + Test that we need to pass in both an api key and a data directory. + """ + with pytest.raises(TypeError): + backup = celigo.BackupCeligo() + api_key = "fake" + data_dir = "fakedir" + backup = celigo.BackupCeligo(data_dir, api_key) +