add tests

This commit is contained in:
Tyrel Souza 2016-05-19 10:53:58 -04:00
parent 5cccc4f8e2
commit cccaa995ae
No known key found for this signature in database
GPG Key ID: 2EECB5087209E6A5
5 changed files with 27 additions and 11 deletions

View File

@ -2,4 +2,4 @@ init:
pip install -r requirements.txt
test:
py.test tests
py.test tests.py

View File

@ -1 +1 @@
from .core import BackupCeligo
from core import BackupCeligo

View File

@ -26,7 +26,14 @@ 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 """
@ -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):
"""

View File

16
tests.py Normal file
View File

@ -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)