Пример #1
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)
Пример #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)
Пример #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)
Пример #4
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)
Пример #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)
Пример #6
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], )
        })
Пример #7
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)