dataimport/test/test_sqlgenstore.py
author Julien Cristau <julien.cristau@logilab.fr>
Wed, 02 Dec 2015 15:24:03 +0100
changeset 11028 66f94d7f9ca7
parent 10987 a945fe89b33f
permissions -rw-r--r--
[dataimport] make eids_seq_range as massive store instance attribute again I changed it to a class attribute recently, but on further thought (and prompting from Adrien) it seems to make more sense as an instance attribute.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10987
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
#
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
# This program is free software: you can redistribute it and/or modify it under
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
# the terms of the GNU Lesser General Public License as published by the Free
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
# Software Foundation, either version 2.1 of the License, or (at your option)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
# any later version.
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
#
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
# This program is distributed in the hope that it will be useful, but WITHOUT
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    12
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    13
# details.
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    14
#
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    15
# You should have received a copy of the GNU Lesser General Public License along
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    16
# with this program. If not, see <http://www.gnu.org/licenses/>.
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    17
"""SQL object store test case"""
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    18
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
import itertools
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    20
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    21
from cubicweb.dataimport import ucsvreader
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    22
from cubicweb.devtools import testlib, PostgresApptestConfiguration
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    23
from cubicweb.devtools import startpgcluster, stoppgcluster
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    24
from cubicweb.dataimport.pgstore import SQLGenObjectStore
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    25
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    26
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    27
def setUpModule():
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    28
    startpgcluster(__file__)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
def tearDownModule(*args):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
    stoppgcluster(__file__)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    34
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    35
class SQLGenImportSimpleTC(testlib.CubicWebTC):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    36
    configcls = PostgresApptestConfiguration
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    37
    appid = 'data-massimport'
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    38
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    39
    def cast(self, _type, value):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    40
        try:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    41
            return _type(value)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    42
        except ValueError:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    43
            return None
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    44
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    45
    def push_geonames_data(self, dumpname, store):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    46
        # Push timezones
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    47
        cnx = store._cnx
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    48
        for code, gmt, dst, raw_offset in ucsvreader(open(self.datapath('timeZones.txt'), 'rb'),
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    49
                                                     delimiter='\t'):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    50
            cnx.create_entity('TimeZone', code=code, gmt=float(gmt),
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    51
                                    dst=float(dst), raw_offset=float(raw_offset))
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    52
        timezone_code = dict(cnx.execute('Any C, X WHERE X is TimeZone, X code C'))
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    53
        cnx.commit()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    54
        # Push data
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    55
        for ind, infos in enumerate(ucsvreader(open(dumpname, 'rb'),
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    56
                                               delimiter='\t',
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    57
                                               ignore_errors=True)):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    58
            if ind > 99:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    59
                break
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    60
            latitude = self.cast(float, infos[4])
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    61
            longitude = self.cast(float, infos[5])
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    62
            population = self.cast(int, infos[14])
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    63
            elevation = self.cast(int, infos[15])
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    64
            gtopo = self.cast(int, infos[16])
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    65
            feature_class = infos[6]
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    66
            if len(infos[6]) != 1:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    67
                feature_class = None
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    68
            entity = {'name': infos[1],
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    69
                      'asciiname': infos[2],
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    70
                      'alternatenames': infos[3],
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    71
                      'latitude': latitude, 'longitude': longitude,
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    72
                      'feature_class': feature_class,
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    73
                      'alternate_country_code':infos[9],
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    74
                      'admin_code_3': infos[12],
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    75
                      'admin_code_4': infos[13],
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    76
                      'population': population, 'elevation': elevation,
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    77
                      'gtopo30': gtopo, 'timezone': timezone_code.get(infos[17]),
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    78
                      'cwuri':  u'http://sws.geonames.org/%s/' % int(infos[0]),
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    79
                      'geonameid': int(infos[0]),
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    80
                      }
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    81
            store.prepare_insert_entity('Location', **entity)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    82
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    83
    def test_autoflush_metadata(self):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    84
        with self.admin_access.repo_cnx() as cnx:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    85
            crs = cnx.system_sql('SELECT * FROM entities WHERE type=%(t)s',
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    86
                                 {'t': 'Location'})
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    87
            self.assertEqual(len(crs.fetchall()), 0)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    88
            store = SQLGenObjectStore(cnx)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    89
            store.prepare_insert_entity('Location', name=u'toto')
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    90
            store.flush()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    91
            store.commit()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    92
            cnx.commit()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    93
        with self.admin_access.repo_cnx() as cnx:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    94
            crs = cnx.system_sql('SELECT * FROM entities WHERE type=%(t)s',
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    95
                                 {'t': 'Location'})
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    96
            self.assertEqual(len(crs.fetchall()), 1)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    97
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    98
    def test_sqlgenstore_etype_metadata(self):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    99
        with self.admin_access.repo_cnx() as cnx:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   100
            store = SQLGenObjectStore(cnx)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   101
            timezone_eid = store.prepare_insert_entity('TimeZone')
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   102
            store.prepare_insert_entity('Location', timezone=timezone_eid)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   103
            store.flush()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   104
            store.commit()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   105
            eid, etname = cnx.execute('Any X, TN WHERE X timezone TZ, X is T, '
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   106
                                      'T name TN')[0]
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   107
            self.assertEqual(cnx.entity_from_eid(eid).cw_etype, etname)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   108
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   109
    def test_simple_insert(self):
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   110
        with self.admin_access.repo_cnx() as cnx:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   111
            store = SQLGenObjectStore(cnx)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   112
            self.push_geonames_data(self.datapath('geonames.csv'), store)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   113
            store.flush()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   114
            store.commit()
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   115
        with self.admin_access.repo_cnx() as cnx:
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   116
            rset = cnx.execute('Any X WHERE X is Location')
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   117
            self.assertEqual(len(rset), 100)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   118
            rset = cnx.execute('Any X WHERE X is Location, X timezone T')
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   119
            self.assertEqual(len(rset), 100)
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   120
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   121
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   122
if __name__ == '__main__':
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   123
    from logilab.common.testlib import unittest_main
a945fe89b33f [dataimport] add tests for SQLGenObjectStore (closes #9177565)
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   124
    unittest_main()