<s> import pandas as pd <EOL> from db import DemoDB , DB , list_profiles , remove_profile <EOL> import unittest <EOL> class PandaSQLTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . db = DemoDB ( ) <EOL> def test_query_rowsum ( self ) : <EOL> df = self . db . query ( "<STR_LIT>" ) <EOL> self . assertEqual ( len ( df ) , <NUM_LIT> ) <EOL> def test_query_groupby ( self ) : <EOL> q = "<STR_LIT>" <EOL> df = self . db . query ( q ) <EOL> self . assertEqual ( len ( df ) , <NUM_LIT> ) <EOL> def test_query_from_file_rowsum ( self ) : <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> df = self . db . query_from_file ( "<STR_LIT>" ) <EOL> self . assertEqual ( len ( df ) , <NUM_LIT> ) <EOL> def test_add_profile ( self ) : <EOL> profiles = list_profiles ( ) <EOL> self . db . save_credentials ( profile = "<STR_LIT>" ) <EOL> self . assertEqual ( len ( profiles ) + <NUM_LIT:1> , len ( list_profiles ( ) ) ) <EOL> remove_profile ( "<STR_LIT>" ) <EOL> def test_remove_profile ( self ) : <EOL> profiles = list_profiles ( ) <EOL> self . db . save_credentials ( profile = "<STR_LIT>" ) <EOL> self . assertEqual ( len ( profiles ) + <NUM_LIT:1> , len ( list_profiles ( ) ) ) <EOL> remove_profile ( "<STR_LIT>" ) <EOL> def test_list_profiles ( self ) : <EOL> self . db . save_credentials ( profile = "<STR_LIT>" ) <EOL> self . assertTrue ( len ( list_profiles ( ) ) > <NUM_LIT:0> ) <EOL> remove_profile ( "<STR_LIT>" ) <EOL> def test_table_head ( self ) : <EOL> self . assertEqual ( len ( self . db . tables . Artist . head ( ) ) , <NUM_LIT:6> ) <EOL> def test_table_all ( self ) : <EOL> self . assertEqual ( len ( self . db . tables . Artist . all ( ) ) , <NUM_LIT> ) <EOL> def test_table_select ( self ) : <EOL> df = self . db . tables . Artist . select ( "<STR_LIT>" , "<STR_LIT:Name>" ) <EOL> self . assertEqual ( df . shape , ( <NUM_LIT> , <NUM_LIT:2> ) ) <EOL> def test_table_sample ( self ) : <EOL> df = self . db . tables . Artist . sample ( n = <NUM_LIT:10> ) <EOL> self . assertEqual ( len ( df ) , <NUM_LIT:10> ) <EOL> def test_table_uniqe ( self ) : <EOL> df = self . db . tables . Track . unique ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( len ( df ) , <NUM_LIT> ) <EOL> def test_column_head ( self ) : <EOL> col = self . db . tables . Track . TrackId . head ( ) <EOL> self . assertEqual ( len ( col ) , <NUM_LIT:6> ) <EOL> def test_column_all ( self ) : <EOL> col = self . db . tables . Track . TrackId . all ( ) <EOL> self . assertEqual ( len ( col ) , <NUM_LIT> ) <EOL> def test_column_sample ( self ) : <EOL> col = self . db . tables . Track . TrackId . sample ( n = <NUM_LIT:10> ) <EOL> self . assertEqual ( len ( col ) , <NUM_LIT:10> ) <EOL> def test_column_unique ( self ) : <EOL> col = self . db . tables . Customer . Country . unique ( ) <EOL> self . assertEqual ( len ( col ) , <NUM_LIT> ) <EOL> def test_table_keys_per_column ( self ) : <EOL> short_db = DemoDB ( keys_per_column = <NUM_LIT:1> ) <EOL> self . assertEqual ( """<STR_LIT>""" . strip ( ) , <EOL> '<STR_LIT>' . format ( short_db . tables . Track . __repr__ ( ) ) . strip ( ) ) <EOL> def tearDown ( self ) : <EOL> pass <EOL> def test_table_count_rows ( self ) : <EOL> count = self . db . tables . Invoice . count <EOL> self . assertEqual ( count , <NUM_LIT> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
