server/test/unittest_schema2sql.py
author David Douard <david.douard@logilab.fr>
Wed, 22 Jul 2015 19:50:50 +0200
changeset 10551 1182f5f16a3d
parent 10481 6ac4b1726e9f
child 11289 3e69bccc2022
permissions -rw-r--r--
[datafeed] fix typo in DataFeedXMLParser.is_deleted (closes #5729755)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
# copyright 2004-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
#
10200
cceb2c7c02f4 Use our version of schema2sql
Julien Cristau <julien.cristau@logilab.fr>
parents: 10199
diff changeset
     4
# This file is part of CubicWeb.
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
#
10200
cceb2c7c02f4 Use our version of schema2sql
Julien Cristau <julien.cristau@logilab.fr>
parents: 10199
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
# any later version.
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
#
10200
cceb2c7c02f4 Use our version of schema2sql
Julien Cristau <julien.cristau@logilab.fr>
parents: 10199
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT ANY
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    13
# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    14
# details.
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    15
#
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
10200
cceb2c7c02f4 Use our version of schema2sql
Julien Cristau <julien.cristau@logilab.fr>
parents: 10199
diff changeset
    17
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
cceb2c7c02f4 Use our version of schema2sql
Julien Cristau <julien.cristau@logilab.fr>
parents: 10199
diff changeset
    18
"""unit tests for module cubicweb.server.schema2sql
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
"""
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    20
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    21
import os.path as osp
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    22
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    23
from logilab.common.testlib import TestCase, unittest_main
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    24
from logilab.database import get_db_helper
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    25
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    26
from yams.reader import SchemaLoader
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    27
from cubicweb.server import schema2sql
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    28
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
schema2sql.SET_DEFAULT = True
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
DATADIR = osp.abspath(osp.join(osp.dirname(__file__), 'data-schema2sql'))
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
schema = SchemaLoader().load([DATADIR])
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    34
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    35
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    36
EXPECTED_DATA_NO_DROP = """
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    37
CREATE TABLE Affaire(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    38
 sujet varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    39
 ref varchar(12),
10201
989bbadbcd8d Add foreign key for inline relations
Julien Cristau <julien.cristau@logilab.fr>
parents: 10200
diff changeset
    40
 inline_rel integer REFERENCES entities (eid)
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    41
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    42
CREATE INDEX affaire_inline_rel_idx ON Affaire(inline_rel);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    43
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    44
CREATE TABLE Company(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    45
 name text
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    46
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    47
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    48
CREATE TABLE Datetest(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    49
 dt1 timestamp,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    50
 dt2 timestamp,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    51
 d1 date,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    52
 d2 date,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    53
 t1 time,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    54
 t2 time
10444
fb7c1013189e [schema2sql] support NOW and TODAY in check constraints
Julien Cristau <julien.cristau@logilab.fr>
parents: 10443
diff changeset
    55
, CONSTRAINT cstredd407706bdfbd2285714dd689e8fcc0 CHECK(d1 <= CAST(clock_timestamp() AS DATE))
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    56
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    57
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    58
CREATE TABLE Division(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    59
 name text
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    60
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    61
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    62
CREATE TABLE EPermission(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    63
 name varchar(100) NOT NULL
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    64
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    65
CREATE INDEX epermission_name_idx ON EPermission(name);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    66
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    67
CREATE TABLE Eetype(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    68
 name varchar(64) UNIQUE NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    69
 description text,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    70
 meta boolean,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    71
 final boolean,
10201
989bbadbcd8d Add foreign key for inline relations
Julien Cristau <julien.cristau@logilab.fr>
parents: 10200
diff changeset
    72
 initial_state integer REFERENCES entities (eid)
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    73
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    74
CREATE INDEX eetype_name_idx ON Eetype(name);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    75
CREATE INDEX eetype_initial_state_idx ON Eetype(initial_state);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    76
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    77
CREATE TABLE Employee(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    78
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    79
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    80
CREATE TABLE Note(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    81
 date varchar(10),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    82
 type varchar(1),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    83
 para varchar(512)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    84
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    85
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    86
CREATE TABLE Person(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    87
 nom varchar(64) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    88
 prenom varchar(64),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    89
 sexe varchar(1) DEFAULT 'M',
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    90
 promo varchar(6),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    91
 titre varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    92
 adel varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    93
 ass varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    94
 web varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    95
 tel integer,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    96
 fax integer,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    97
 datenaiss date,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    98
 test boolean,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    99
 salary float
10443
2d3834df64ab [schema2sql] insert some constraints into the backend
Julien Cristau <julien.cristau@logilab.fr>
parents: 10204
diff changeset
   100
, CONSTRAINT cstr41fe7db9ce1d5be95de2477e26590386 CHECK(promo IN ('bon', 'pasbon'))
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   101
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   102
CREATE UNIQUE INDEX unique_e6c2d219772dbf1715597f7d9a6b3892 ON Person(nom,prenom);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   103
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   104
CREATE TABLE Salaried(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   105
 nom varchar(64) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   106
 prenom varchar(64),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   107
 sexe varchar(1) DEFAULT 'M',
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   108
 promo varchar(6),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   109
 titre varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   110
 adel varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   111
 ass varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   112
 web varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   113
 tel integer,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   114
 fax integer,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   115
 datenaiss date,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   116
 test boolean,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   117
 salary float
10443
2d3834df64ab [schema2sql] insert some constraints into the backend
Julien Cristau <julien.cristau@logilab.fr>
parents: 10204
diff changeset
   118
, CONSTRAINT cstrc8556fcc665865217761cdbcd220cae0 CHECK(promo IN ('bon', 'pasbon'))
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   119
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   120
CREATE UNIQUE INDEX unique_98da0f9de8588baa8966f0b1a6f850a3 ON Salaried(nom,prenom);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   121
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   122
CREATE TABLE Societe(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   123
 nom varchar(64),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   124
 web varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   125
 tel integer,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   126
 fax integer,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   127
 rncs varchar(32),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   128
 ad1 varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   129
 ad2 varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   130
 ad3 varchar(128),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   131
 cp varchar(12),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   132
 ville varchar(32)
10443
2d3834df64ab [schema2sql] insert some constraints into the backend
Julien Cristau <julien.cristau@logilab.fr>
parents: 10204
diff changeset
   133
, CONSTRAINT cstrc51dd462e9f6115506a0fe468d4c8114 CHECK(fax <= tel)
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   134
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   135
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   136
CREATE TABLE State(
10204
f8ccae1e271d Add reference from etype table's eid column to the entities table
Julien Cristau <julien.cristau@logilab.fr>
parents: 10202
diff changeset
   137
 eid integer PRIMARY KEY REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   138
 name varchar(256) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   139
 description text
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   140
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   141
CREATE INDEX state_name_idx ON State(name);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   142
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   143
CREATE TABLE Subcompany(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   144
 name text
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   145
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   146
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   147
CREATE TABLE Subdivision(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   148
 name text
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   149
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   150
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   151
CREATE TABLE pkginfo(
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   152
 modname varchar(30) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   153
 version varchar(10) DEFAULT '0.1' NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   154
 copyright text NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   155
 license varchar(3),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   156
 short_desc varchar(80) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   157
 long_desc text NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   158
 author varchar(100) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   159
 author_email varchar(100) NOT NULL,
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   160
 mailinglist varchar(100),
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   161
 debian_handler varchar(6)
10443
2d3834df64ab [schema2sql] insert some constraints into the backend
Julien Cristau <julien.cristau@logilab.fr>
parents: 10204
diff changeset
   162
, CONSTRAINT cstr70f766f834557c715815d76f0a0db956 CHECK(license IN ('GPL', 'ZPL'))
2d3834df64ab [schema2sql] insert some constraints into the backend
Julien Cristau <julien.cristau@logilab.fr>
parents: 10204
diff changeset
   163
, CONSTRAINT cstr831a117424d0007ae0278cc15f344f5e CHECK(debian_handler IN ('machin', 'bidule'))
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   164
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   165
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   166
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   167
CREATE TABLE concerne_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   168
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   169
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   170
  CONSTRAINT concerne_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   171
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   172
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   173
CREATE INDEX concerne_relation_from_idx ON concerne_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   174
CREATE INDEX concerne_relation_to_idx ON concerne_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   175
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   176
CREATE TABLE division_of_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   177
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   178
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   179
  CONSTRAINT division_of_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   180
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   181
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   182
CREATE INDEX division_of_relation_from_idx ON division_of_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   183
CREATE INDEX division_of_relation_to_idx ON division_of_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   184
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   185
CREATE TABLE evaluee_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   186
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   187
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   188
  CONSTRAINT evaluee_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   189
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   190
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   191
CREATE INDEX evaluee_relation_from_idx ON evaluee_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   192
CREATE INDEX evaluee_relation_to_idx ON evaluee_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   193
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   194
CREATE TABLE next_state_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   195
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   196
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   197
  CONSTRAINT next_state_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   198
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   200
CREATE INDEX next_state_relation_from_idx ON next_state_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   201
CREATE INDEX next_state_relation_to_idx ON next_state_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   202
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   203
CREATE TABLE obj_wildcard_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   204
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   205
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   206
  CONSTRAINT obj_wildcard_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   207
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   208
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   209
CREATE INDEX obj_wildcard_relation_from_idx ON obj_wildcard_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   210
CREATE INDEX obj_wildcard_relation_to_idx ON obj_wildcard_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   211
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   212
CREATE TABLE require_permission_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   213
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   214
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   215
  CONSTRAINT require_permission_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   216
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   217
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   218
CREATE INDEX require_permission_relation_from_idx ON require_permission_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   219
CREATE INDEX require_permission_relation_to_idx ON require_permission_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   220
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   221
CREATE TABLE state_of_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   222
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   223
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   224
  CONSTRAINT state_of_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   225
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   226
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   227
CREATE INDEX state_of_relation_from_idx ON state_of_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   228
CREATE INDEX state_of_relation_to_idx ON state_of_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   229
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   230
CREATE TABLE subcompany_of_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   231
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   232
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   233
  CONSTRAINT subcompany_of_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   234
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   235
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   236
CREATE INDEX subcompany_of_relation_from_idx ON subcompany_of_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   237
CREATE INDEX subcompany_of_relation_to_idx ON subcompany_of_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   238
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   239
CREATE TABLE subdivision_of_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   240
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   241
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   242
  CONSTRAINT subdivision_of_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   243
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   244
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   245
CREATE INDEX subdivision_of_relation_from_idx ON subdivision_of_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   246
CREATE INDEX subdivision_of_relation_to_idx ON subdivision_of_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   247
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   248
CREATE TABLE subj_wildcard_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   249
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   250
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   251
  CONSTRAINT subj_wildcard_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   252
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   253
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   254
CREATE INDEX subj_wildcard_relation_from_idx ON subj_wildcard_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   255
CREATE INDEX subj_wildcard_relation_to_idx ON subj_wildcard_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   256
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   257
CREATE TABLE sym_rel_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   258
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   259
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   260
  CONSTRAINT sym_rel_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   261
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   262
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   263
CREATE INDEX sym_rel_relation_from_idx ON sym_rel_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   264
CREATE INDEX sym_rel_relation_to_idx ON sym_rel_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   265
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   266
CREATE TABLE travaille_relation (
10202
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   267
  eid_from INTEGER NOT NULL REFERENCES entities (eid),
aaabcb64f77f Use foreign keys for relations tables
Julien Cristau <julien.cristau@logilab.fr>
parents: 10201
diff changeset
   268
  eid_to INTEGER NOT NULL REFERENCES entities (eid),
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   269
  CONSTRAINT travaille_relation_p_key PRIMARY KEY(eid_from, eid_to)
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   270
);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   271
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   272
CREATE INDEX travaille_relation_from_idx ON travaille_relation(eid_from);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   273
CREATE INDEX travaille_relation_to_idx ON travaille_relation(eid_to);
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   274
"""
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   275
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   276
class SQLSchemaTC(TestCase):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   277
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   278
    def test_known_values(self):
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   279
        dbhelper = get_db_helper('postgres')
10481
6ac4b1726e9f [schema2sql] properly consider skip_relations parameters.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10444
diff changeset
   280
        output = schema2sql.schema2sql(dbhelper, schema, skip_relations=('works_for',))
10199
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   281
        self.assertMultiLineEqual(EXPECTED_DATA_NO_DROP.strip(), output.strip())
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   282
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   283
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   284
if __name__ == '__main__':
218c28bff695 Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   285
    unittest_main()