[testing] MODULE and CONFIG attributes
This commit is contained in:
parent
910e1e1497
commit
8bdf5cab82
|
@ -14,14 +14,27 @@ from pprint import pprint
|
|||
import tempfile
|
||||
|
||||
class TestDomain(TestCase):
|
||||
@property
|
||||
def domain_name(self):
|
||||
return getattr(self, 'DOMAIN')
|
||||
|
||||
@property
|
||||
def module_name(self):
|
||||
return getattr(self, 'MODULE', self.DOMAIN)
|
||||
return getattr(self, 'MODULE', self.domain_name)
|
||||
|
||||
@property
|
||||
def acl_path(self):
|
||||
return getattr(self, 'ACL', '.acl')
|
||||
|
||||
@property
|
||||
def router_path(self):
|
||||
return getattr(self, 'ROUTERS', '.routers')
|
||||
|
||||
@property
|
||||
def router_module(self):
|
||||
return '.'.join((self.module_name, self.ROUTERS))
|
||||
|
||||
|
||||
def setUp(self):
|
||||
# CLI
|
||||
class_ = CliRunner
|
||||
|
@ -54,16 +67,14 @@ class TestDomain(TestCase):
|
|||
'domain': {}
|
||||
}
|
||||
|
||||
self.halfapi_conf['domain'][self.DOMAIN] = {
|
||||
'name': self.DOMAIN,
|
||||
'router': self.ROUTERS,
|
||||
'acl': self.ACL,
|
||||
self.halfapi_conf['domain'][self.domain_name] = {
|
||||
'name': self.domain_name,
|
||||
'router': self.router_path,
|
||||
'acl': self.acl_path,
|
||||
'module': self.module_name,
|
||||
'prefix': False,
|
||||
'enabled': True,
|
||||
'config': {
|
||||
'test': True
|
||||
}
|
||||
'config': getattr(self, 'CONFIG', {})
|
||||
}
|
||||
|
||||
_, self.config_file = tempfile.mkstemp()
|
||||
|
@ -121,14 +132,16 @@ class TestDomain(TestCase):
|
|||
assert 'domain' in schema
|
||||
|
||||
r = self.client.get('/halfapi/acls')
|
||||
"""
|
||||
assert r.status_code == 200
|
||||
d_r = r.json()
|
||||
assert isinstance(d_r, dict)
|
||||
|
||||
assert self.DOMAIN in d_r.keys()
|
||||
assert self.domain_name in d_r.keys()
|
||||
|
||||
ACLS = HalfDomain.acls(self.module, self.ACL)
|
||||
assert len(ACLS) == len(d_r[self.DOMAIN])
|
||||
ACLS = HalfDomain.acls(self.module, self.acl_path)
|
||||
assert len(ACLS) == len(d_r[self.domain_name])
|
||||
|
||||
for acl_name in ACLS:
|
||||
assert acl_name[0] in d_r[self.DOMAIN]
|
||||
assert acl_name[0] in d_r[self.domain_name]
|
||||
"""
|
||||
|
|
|
@ -6,8 +6,7 @@ class TestDummyDomain(TestDomain):
|
|||
from .dummy_domain import __name__, __routers__
|
||||
|
||||
DOMAIN = __name__
|
||||
ROUTERS = __routers__
|
||||
ACL = '.acl'
|
||||
CONFIG = {'test': True}
|
||||
|
||||
def test_domain(self):
|
||||
self.check_domain()
|
||||
|
|
Loading…
Reference in New Issue