<s> import os <EOL> import sqlite3 <EOL> import unittest <EOL> from thanos import * <EOL> BASE_DIR = os . path . abspath ( os . path . join ( '<STR_LIT:.>' , os . pardir ) ) <EOL> PROJECT_DIR = os . path . join ( BASE_DIR , '<STR_LIT>' ) <EOL> DB_NAME = "<STR_LIT>" <EOL> SCHEMA = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" "<STR_LIT:)>" <EOL> VALUES = ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:bar>" , <NUM_LIT:2> , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:3> , "<STR_LIT>" ) , <EOL> ) <EOL> class TestDatabase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def _connect ( self ) : <EOL> connection = sqlite3 . connect ( DB_NAME ) <EOL> cursor = connection . cursor ( ) <EOL> return ( connection , cursor ) <EOL> def set_up ( self ) : <EOL> """<STR_LIT>""" <EOL> test = os . path . isfile ( DB_NAME ) <EOL> connection . close ( ) <EOL> self . assertEqual ( test , True ) <EOL> def test_db_schema_correct ( self ) : <EOL> """<STR_LIT>""" <EOL> connection , cursor = self . _connect ( ) <EOL> cursor . execute ( "<STR_LIT>" ) <EOL> test = cursor . fetchall ( ) <EOL> result = [ ( '<STR_LIT>' , ) ] <EOL> self . assertEqual ( test , result ) <EOL> connection . close ( ) <EOL> def test_db_schema_incorrect ( self ) : <EOL> connection , cursor = self . _connect ( ) <EOL> cursor . execute ( "<STR_LIT>" ) <EOL> test = False <EOL> self . assertFalse ( test ) <EOL> def test_db_values_correct ( self ) : <EOL> connection , cursor = self . _connect ( ) <EOL> test = cursor . execute ( '<STR_LIT>' ) . fetchall ( ) <EOL> result = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:bar>' , <NUM_LIT:2> , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:3> , '<STR_LIT>' ) <EOL> ] <EOL> self . assertEqual ( test , result ) <EOL> connection . close ( ) <EOL> def tear_down ( self ) : <EOL> os . remove ( DB_NAME ) <EOL> test = os . path . isfile ( DB_NAME ) <EOL> self . assertEqual ( test , False ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
