Exemple #1
0
            class SimplestRelation(Relation):
                name = Column(primary=True,
                              index_name='name_a',
                              no_index=False)
                value = Column(no_index=False)

                records = (('name_a', 1), ('name_b', 2))
Exemple #2
0
    def test_check_uniqueness_restriction_success(self):
        column_1 = Column()
        column_1.initialize("column_1")

        records = (Record([column_1], ["uuid_1"]), Record([column_1], ["uuid_2"]))

        column_1.check_uniqueness_restriction(records)
Exemple #3
0
class RelationSourceRelation(Relation):
    name = Column(primary=True, no_index=False, primary_checks=True)
    val_1 = Column(no_index=False)
    rel = Column(related_name='rel_source', no_index=False)

    records = (('STATE_1', 'value_1', RelationDestinationRelation.STATE_1),
               ('STATE_2', 'value_2', RelationDestinationRelation.STATE_2))
Exemple #4
0
 def test_equality(self):
     columns = (Column(name='col_1'), Column(name='col_2'))
     data = (1, 2)
     r_1 = Record(columns=columns, data=data)
     r_2 = Record(columns=columns, data=data)
     self.assertNotEqual(r_1, r_2)
     self.assertEqual(r_1, r_1)
Exemple #5
0
    def test_check_uniqueness_restriction_exception(self):
        column_1 = Column()
        column_1.initialize("column_1")

        records = (Record([column_1], ["uuid_1"]), Record([column_1], ["uuid_1"]))

        self.assertRaises(exceptions.DuplicateValueError, column_1.check_uniqueness_restriction, records)
Exemple #6
0
 def test_wrong_data_length(self):
     columns = (Column(name='col_1'), Column(name='col_2'))
     data = (1, 2, 3)
     self.assertRaises(exceptions.ColumnsNumberError,
                       Record,
                       columns=columns,
                       data=data)
Exemple #7
0
    def test_check_single_type_restriction_success(self):
        column_1 = Column()
        column_1.initialize("column_1")

        records = (Record([column_1], ["str_1"]), Record([column_1], ["str_2"]))

        column_1.check_single_type_restriction(records)
Exemple #8
0
    def test_check_single_type_restriction_exception(self):
        column_1 = Column()
        column_1.initialize("column_1")

        records = (Record([column_1], [1]), Record([column_1], ["str_2"]))

        self.assertRaises(exceptions.SingleTypeError, column_1.check_single_type_restriction, records)
Exemple #9
0
    def test_get_index_not_unique(self):
        column_1 = Column(unique=False)
        column_1.initialize("column_1")

        records = (Record([column_1], ["str_1"]), Record([column_1], ["str_2"]))

        self.assertEqual(column_1.get_index(records), {"str_1": (records[0],), "str_2": (records[1],)})
Exemple #10
0
    def test_check_single_type_restriction_exception(self):
        column_1 = Column()
        column_1.initialize('column_1')

        records = (Record([column_1], [1]), Record([column_1], ['str_2']))

        self.assertRaises(exceptions.SingleTypeError,
                          column_1.check_single_type_restriction, records)
Exemple #11
0
    def test_get_index__no_index(self):
        column_1 = Column(no_index=True)
        column_1.initialize('column_1')

        records = ( Record([column_1], ['str_1']),
                    Record([column_1], ['str_2']))

        self.assertEqual(column_1.get_index(records), None)
Exemple #12
0
    def test_get_index_not_unique(self):
        column_1 = Column(unique=False)
        column_1.initialize('column_1')

        records = ( Record([column_1], ['str_1']),
                    Record([column_1], ['str_2']))

        self.assertEqual(column_1.get_index(records), {'str_1': (records[0], ),
                                                       'str_2': (records[1], )})
Exemple #13
0
    def test_check_uniqueness_restriction_exception(self):
        column_1 = Column()
        column_1.initialize('column_1')

        records = (Record([column_1],
                          ['uuid_1']), Record([column_1], ['uuid_1']))

        self.assertRaises(exceptions.DuplicateValueError,
                          column_1.check_uniqueness_restriction, records)
Exemple #14
0
            class SimplestRelation(Relation):
                name = Column(primary=True,
                              no_index=False,
                              primary_checks=True)
                is_name = Column(primary=True,
                                 no_index=False,
                                 primary_checks=True)

                records = (('name_a', 'name_c'), ('name_b', 'name'))
Exemple #15
0
            class RelationSourceRelation(Relation):
                name = Column(primary=True)
                val_1 = Column()
                rel = Column(related_name='rel_source')

                # "name" duplicate primary attribute of RelationDestinationRelation
                records = (('name', 'value_1',
                            RelationDestinationRelation.STATE_1),
                           ('STATE_2', 'value_2',
                            RelationDestinationRelation.STATE_2))
Exemple #16
0
            class RelationSourceRelation(Relation):
                name = Column(primary=True)
                val_1 = Column()
                rel = Column(related_name='rel_source')

                records = (
                    ('STATE_1', 'value_1',
                     1),  # just any type without .set_related_name
                    ('STATE_2', 'value_2',
                     RelationDestinationRelation.STATE_2))
Exemple #17
0
    def test_get_index_not_unique(self):
        column_1 = Column(unique=False)
        column_1.initialize('column_1')

        records = (Record([column_1], ['str_1']), Record([column_1],
                                                         ['str_2']))

        self.assertEqual(column_1.get_index(records), {
            'str_1': (records[0], ),
            'str_2': (records[1], )
        })
Exemple #18
0
class IndexesRelation(Relation):
    name = Column(primary=True, no_index=False, primary_checks=True)
    val_1 = Column(no_index=False)
    val_2 = Column(unique=False, no_index=False)
    val_3 = Column(index_name='val_3_index', no_index=False)

    records = (
        ('rec_1', 'val_1_1', 'val_2_1', 'val_3_1'),
        ('rec_2', 'val_1_2', 'val_2_2', 'val_3_2'),
        ('rec_3', 'val_1_3', 'val_2_2', 'val_3_3'),
        ('rec_4', 'val_1_4', 'val_2_4', 'val_3_4'),
    )
Exemple #19
0
    def test_check_single_type_restriction_success(self):
        column_1 = Column()
        column_1.initialize('column_1')

        records = (Record([column_1], ['str_1']), Record([column_1],
                                                         ['str_2']))

        column_1.check_single_type_restriction(records)
Exemple #20
0
    def test_check_uniqueness_restriction_success(self):
        column_1 = Column()
        column_1.initialize('column_1')

        records = (Record([column_1],
                          ['uuid_1']), Record([column_1], ['uuid_2']))

        column_1.check_uniqueness_restriction(records)
Exemple #21
0
class SimplestRelation(Relation):
    name = Column(no_index=False)
    value = Column(no_index=False)

    records = (('name_a', 1), ('name_b', 2))
Exemple #22
0
class RelationDestinationRelation(Relation):
    name = Column(primary=True, no_index=False, primary_checks=True)
    val_1 = Column(no_index=False)

    records = (('STATE_1', 'value_1'), ('STATE_2', 'value_2'))
Exemple #23
0
            class SimplestRelation(Relation):
                name = Column()
                value = Column(unique=True)

                records = (('name_a', 1), ('name_b', 1))
Exemple #24
0
 def test_columns_values(self):
     columns = (Column(name='col_1'), Column(name='col_2'))
     data = (1, 2)
     r = Record(columns=columns, data=data)
     self.assertEqual(r.col_1, 1)
     self.assertEqual(r.col_2, 2)
Exemple #25
0
class Enum(Relation):
    name = Column(primary=True, no_index=True, primary_checks=True)
    value = Column(external=True, no_index=True)
Exemple #26
0
            class SimplestRelation(Relation):
                name = Column(primary=True, unique=False)
                value = Column()

                records = (('name_a', 1), ('name_b', 1))
Exemple #27
0
 def test_default_index_name(self):
     column = Column()
     column.initialize(name='test')
     self.assertEqual(column.index_name, 'index_test')
Exemple #28
0
 def test_custom_index_name(self):
     column = Column(index_name='my_index')
     column.initialize(name='test')
     self.assertEqual(column.index_name, 'my_index')
Exemple #29
0
 def test_custom_index_name(self):
     column = Column(index_name="my_index")
     column.initialize(name="test")
     self.assertEqual(column.index_name, "my_index")
Exemple #30
0
class SimplestEnum(Relation):
    name = Column(primary=True, no_index=False, primary_checks=True)
    value = Column(external=True, no_index=False)

    records = (('state_1', 'val_1'), ('state_2', 'val_2'))
Exemple #31
0
 def test_default_index_name(self):
     column = Column()
     column.initialize(name='test')
     self.assertEqual(column.index_name, 'index_test')
Exemple #32
0
 class ChildRelation(BaseRelation):
     value = Column(unique=False, no_index=False)
     records = (('id_1', 1), ('id_2', 2))
Exemple #33
0
 class BaseRelation(Relation):
     name = Column(primary=True, no_index=False)
     value = Column(no_index=False)
     records = (('id_0', 0), )
Exemple #34
0
class EnumWith2Primaries(Relation):

    name = Column(primary=True, no_index=False, primary_checks=True)
    value = Column(primary=True, no_index=False, primary_checks=True)

    records = (('STATE_1', 'value_1'), ('STATE_2', 'value_2'))
Exemple #35
0
            class SimplestRelation(Relation):
                name = Column(external=True)
                value = Column(external=True)

                records = (('name_a', 'name_c'), ('name_b', 'name_d'))
Exemple #36
0
class EmptyRecordsRelation(Relation):
    name = Column(no_index=False)
    value = Column(no_index=False)
Exemple #37
0
            class SimplestRelation(Relation):
                name = Column(primary=True)
                value = Column(primary=True)

                records = (('name_a', 'name_c'), ('name_b', 'name_a'))
Exemple #38
0
    def test_repr(self):
        column = Column(related_name='rel_name')
        column.initialize(name='col_name')

        column._creation_order += 1 # enshure, that creation order will be equal
        self.assertEqual(eval(repr(column)).__dict__, column.__dict__)
Exemple #39
0
 class BaseRelation(Relation):
     name = Column(primary=True)
     value = Column()
Exemple #40
0
 def test_custom_index_name(self):
     column = Column(index_name='my_index')
     column.initialize(name='test')
     self.assertEqual(column.index_name, 'my_index')
Exemple #41
0
 class BaseRelation(Relation):
     name = Column(primary=True, no_index=False)
     value = Column(no_index=False)