<s> import rethinkdb as r <EOL> from remodel . helpers import create_tables , drop_tables , create_indexes <EOL> from remodel . models import Model <EOL> from . import BaseTestCase , DbBaseTestCase <EOL> class CreateTablesTests ( DbBaseTestCase ) : <EOL> def assert_table_created ( self , table ) : <EOL> assert table in r . table_list ( ) . run ( ) <EOL> def test_new_table ( self ) : <EOL> class Artist ( Model ) : <EOL> pass <EOL> create_tables ( ) <EOL> self . assert_table_created ( '<STR_LIT>' ) <EOL> def test_existing_table ( self ) : <EOL> class Artist ( Model ) : <EOL> pass <EOL> create_tables ( ) <EOL> create_tables ( ) <EOL> self . assert_table_created ( '<STR_LIT>' ) <EOL> class DropTablesTests ( DbBaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( DropTablesTests , self ) . setUp ( ) <EOL> class Artist ( Model ) : <EOL> pass <EOL> create_tables ( ) <EOL> def assert_table_dropped ( self , table ) : <EOL> assert table not in r . table_list ( ) . run ( ) <EOL> def test_existing_table ( self ) : <EOL> drop_tables ( ) <EOL> self . assert_table_dropped ( '<STR_LIT>' ) <EOL> def test_dropped_table ( self ) : <EOL> drop_tables ( ) <EOL> drop_tables ( ) <EOL> self . assert_table_dropped ( '<STR_LIT>' ) <EOL> class CreateIndexesTests ( DbBaseTestCase ) : <EOL> def assert_indexes_created ( self , table , indexes ) : <EOL> assert set ( indexes ) == set ( r . table ( table ) . index_list ( ) . run ( ) ) <EOL> def test_new_index ( self ) : <EOL> class Order ( Model ) : <EOL> belongs_to = ( '<STR_LIT>' , ) <EOL> create_tables ( ) <EOL> create_indexes ( ) <EOL> self . assert_indexes_created ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> def test_existing_index ( self ) : <EOL> class Order ( Model ) : <EOL> belongs_to = ( '<STR_LIT>' , ) <EOL> create_tables ( ) <EOL> create_indexes ( ) <EOL> create_indexes ( ) <EOL> self . assert_indexes_created ( '<STR_LIT>' , [ '<STR_LIT>' ] ) </s>
