Esempio n. 1
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],)})
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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], )})
Esempio n. 8
0
 def test_custom_index_name(self):
     column = Column(index_name='my_index')
     column.initialize(name='test')
     self.assertEqual(column.index_name, 'my_index')
Esempio n. 9
0
 def test_default_index_name(self):
     column = Column()
     column.initialize(name='test')
     self.assertEqual(column.index_name, 'index_test')
Esempio n. 10
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__)
Esempio n. 11
0
 def test_custom_index_name(self):
     column = Column(index_name="my_index")
     column.initialize(name="test")
     self.assertEqual(column.index_name, "my_index")