import unittest

import tables

from simphony.io.data_container_description import Record
from simphony.io.tests.abc_data_container_table_check import (
    ABCDataContainerTableCheck)


class CustomRecord(tables.IsDescription):

    index = tables.StringCol(itemsize=16, pos=0)

    class Data(tables.IsDescription):

        name = tables.StringCol(pos=0, itemsize=20)
        direction = tables.Float64Col(pos=1, shape=3)
        status = tables.Int32Col(pos=2)
        label = tables.Int32Col(pos=3)
        material_id = tables.Int32Col(pos=4)
        chemical_specie = tables.StringCol(pos=5, itemsize=20)
        rolling_friction = tables.Float64Col(pos=6)
        volume_fraction = tables.Float64Col(pos=7)

    mask = tables.BoolCol(pos=1, shape=(8,))


class TestDataContainerTable(
        ABCDataContainerTableCheck, unittest.TestCase):

    @property
    def record(self):
        return Record


class TestDataContainerTableWithCustomRecord(
        ABCDataContainerTableCheck, unittest.TestCase):

    @property
    def record(self):
        return CustomRecord


if __name__ == '__main__':
    unittest.main()

@@ -8,16 +8,47 @@
 unittest
+%0Afrom contextlib import closing
 %0A%0Aimport
@@ -114,16 +114,80 @@
  Record%0A
+from simphony.io.data_container_table import DataContainerTable%0A
 from sim
@@ -997,16 +997,656 @@
 Record%0A%0A
+    def test_creating_a_data_container_table_using_default_record(self):%0A        with closing(tables.open_file(self.filename, mode='w')) as handle:%0A            root = handle.root%0A            table = DataContainerTable(root, 'my_data_table')%0A            self.assertEqual(len(table), 0)%0A            self.assertIn('my_data_table', root)%0A            self.assertTrue(table.valid)%0A            data_column = root.my_data_table.colinstances%5B'Data'%5D%0A            expected_column_names = %5B%0A                key.name.lower() for key in self.saved_keys%5D%0A            self.assertItemsEqual(%0A                data_column._v_colnames, expected_column_names)%0A%0A
 %0Aclass T

add a custom test to check the default value for the record argument