add tests
This commit is contained in:
parent
5cccc4f8e2
commit
cccaa995ae
2
Makefile
2
Makefile
@ -2,4 +2,4 @@ init:
|
||||
pip install -r requirements.txt
|
||||
|
||||
test:
|
||||
py.test tests
|
||||
py.test tests.py
|
||||
|
@ -1 +1 @@
|
||||
from .core import BackupCeligo
|
||||
from core import BackupCeligo
|
||||
|
@ -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):
|
||||
"""
|
||||
|
16
tests.py
Normal file
16
tests.py
Normal 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)
|
||||
|
Loading…
Reference in New Issue
Block a user