Allow setting up projects for Attract from unittests
This commit is contained in:
@@ -1,13 +1,28 @@
|
||||
from pillar.tests import PillarTestServer, AbstractPillarTest
|
||||
|
||||
from attract import AttractExtension
|
||||
from attract.setup import setup_for_attract
|
||||
|
||||
|
||||
class AttractTestServer(PillarTestServer):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AttractTestServer, self).__init__(*args, **kwargs)
|
||||
PillarTestServer.__init__(self, *args, **kwargs)
|
||||
|
||||
self.load_extension(AttractExtension(), '/attract')
|
||||
|
||||
|
||||
class AbstractAttractTest(AbstractPillarTest):
|
||||
pillar_server_class = AttractTestServer
|
||||
|
||||
def ensure_project_exists(self, project_overrides=None):
|
||||
project_overrides = dict(
|
||||
picture_header=None,
|
||||
picture_square=None,
|
||||
**(project_overrides or {})
|
||||
)
|
||||
proj_id, project = AbstractPillarTest.ensure_project_exists(self, project_overrides)
|
||||
|
||||
with self.app.test_request_context():
|
||||
attract_project = setup_for_attract(project['url'], replace=True)
|
||||
|
||||
return proj_id, attract_project
|
||||
|
Reference in New Issue
Block a user