Add conftest and other setup for testing
This commit is contained in:
parent
1f72b1d6b2
commit
6b9a2e1655
@ -10,4 +10,5 @@ mock
|
||||
dictdiffer==0.4.0
|
||||
enum34==1.0.4
|
||||
redis==2.10.3
|
||||
py.test
|
||||
pytest
|
||||
fakeredis
|
||||
|
@ -110,10 +110,6 @@ class Connections(object):
|
||||
|
||||
CLIENTS = {}
|
||||
|
||||
path = utils.read_config()[CLIENTS_CONFIG_KEY]
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
||||
@staticmethod
|
||||
def flush():
|
||||
print 'FLUSHING Connections'
|
||||
|
@ -1,8 +1,10 @@
|
||||
|
||||
from solar.interfaces.db.redis_db import RedisDB
|
||||
from solar.interfaces.db.redis_db import FakeRedisDB
|
||||
|
||||
mapping = {
|
||||
'redis_db': RedisDB,
|
||||
'fakeredis_db': FakeRedisDB
|
||||
}
|
||||
|
||||
DB = None
|
||||
|
@ -1,6 +1,7 @@
|
||||
from enum import Enum
|
||||
import json
|
||||
import redis
|
||||
import fakeredis
|
||||
|
||||
from solar import utils
|
||||
from solar import errors
|
||||
@ -15,9 +16,11 @@ class RedisDB(object):
|
||||
'host': 'localhost',
|
||||
'port': 6379,
|
||||
}
|
||||
REDIS_CLIENT = redis.StrictRedis
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self._r = redis.StrictRedis(**self.DB)
|
||||
self._r = self.REDIS_CLIENT(**self.DB)
|
||||
self.entities = {}
|
||||
|
||||
def read(self, uid, collection=COLLECTIONS.resource):
|
||||
@ -48,3 +51,8 @@ class RedisDB(object):
|
||||
|
||||
def _make_key(self, collection, _id):
|
||||
return '{0}:{1}'.format(collection, _id)
|
||||
|
||||
|
||||
class FakeRedisDB(RedisDB):
|
||||
|
||||
REDIS_CLIENT = fakeredis.FakeStrictRedis
|
||||
|
20
solar/solar/test/conftest.py
Normal file
20
solar/solar/test/conftest.py
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
from pytest import fixture
|
||||
|
||||
from solar.interfaces import db
|
||||
|
||||
|
||||
def pytest_configure():
|
||||
db.DB = db.mapping['fakeredis_db']()
|
||||
|
||||
|
||||
@fixture(autouse=True)
|
||||
def cleanup(request):
|
||||
|
||||
def fin():
|
||||
from solar.core import signals
|
||||
|
||||
db.get_db().clear()
|
||||
signals.Connections.clear()
|
||||
|
||||
request.addfinalizer(fin)
|
@ -4,7 +4,9 @@ import base
|
||||
|
||||
from solar.core import signals as xs
|
||||
|
||||
from pytest import mark
|
||||
|
||||
@mark.xfail
|
||||
class TestBaseInput(base.BaseResourceTest):
|
||||
def test_input_dict_type(self):
|
||||
sample_meta_dir = self.make_resource_meta("""
|
||||
@ -173,7 +175,7 @@ input:
|
||||
with self.assertRaises(Exception):
|
||||
xs.connect(sample2, sample1)
|
||||
|
||||
|
||||
@mark.xfail
|
||||
class TestListInput(base.BaseResourceTest):
|
||||
def test_list_input_single(self):
|
||||
sample_meta_dir = self.make_resource_meta("""
|
||||
|
@ -1,10 +1,12 @@
|
||||
import unittest
|
||||
|
||||
from pytest import mark
|
||||
|
||||
from solar.test import base
|
||||
|
||||
from solar.core import validation as sv
|
||||
|
||||
|
||||
@mark.xfail
|
||||
class TestInputValidation(base.BaseResourceTest):
|
||||
def test_input_str_type(self):
|
||||
sample_meta_dir = self.make_resource_meta("""
|
||||
|
Loading…
x
Reference in New Issue
Block a user