|
1
|
|
|
import os |
|
2
|
|
|
import unittest |
|
3
|
|
|
|
|
4
|
|
|
from pyramid.paster import get_appsettings |
|
5
|
|
|
from skosprovider_sqlalchemy.utils import import_provider |
|
6
|
|
|
from sqlalchemy import engine_from_config |
|
7
|
|
|
from sqlalchemy.orm import sessionmaker |
|
8
|
|
|
import transaction |
|
9
|
|
|
from zope.sqlalchemy import ZopeTransactionExtension |
|
10
|
|
|
from skosprovider_sqlalchemy.models import Base, ConceptScheme |
|
11
|
|
|
|
|
12
|
|
|
from atramhasis import main |
|
13
|
|
|
from fixtures.data import trees, geo |
|
14
|
|
|
from fixtures.materials import materials |
|
15
|
|
|
from fixtures.styles_and_cultures import styles_and_cultures |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
here = os.path.dirname(__file__) |
|
19
|
|
|
settings = get_appsettings(os.path.join(here, '../', 'tests/conf_test.ini')) |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class TestConfig(unittest.TestCase): |
|
23
|
|
|
def setUp(self): |
|
24
|
|
|
settings['sqlalchemy.url'] = 'sqlite:///%s/dbtest.sqlite' % here |
|
25
|
|
|
self.engine = engine_from_config(settings, prefix='sqlalchemy.') |
|
26
|
|
|
Base.metadata.drop_all(self.engine) |
|
27
|
|
|
Base.metadata.create_all(self.engine) |
|
28
|
|
|
|
|
29
|
|
|
session_maker = sessionmaker( |
|
30
|
|
|
bind=self.engine, |
|
31
|
|
|
extension=ZopeTransactionExtension() |
|
32
|
|
|
) |
|
33
|
|
|
|
|
34
|
|
|
with transaction.manager: |
|
35
|
|
|
local_session = session_maker() |
|
36
|
|
|
import_provider(trees, ConceptScheme(id=1, uri='urn:x-skosprovider:trees'), local_session) |
|
37
|
|
|
import_provider(materials, ConceptScheme(id=4, uri='urn:x-vioe:materials'), local_session) |
|
38
|
|
|
import_provider(geo, ConceptScheme(id=2), local_session) |
|
39
|
|
|
import_provider(styles_and_cultures, ConceptScheme(id=3), local_session) |
|
40
|
|
|
|
|
41
|
|
|
def test_config(self): |
|
42
|
|
|
app = main({}, **settings) |
|
43
|
|
|
self.assertIsNotNone(app) |