def test_07_read_table_multi_col_multi_rows_diff_col_names(self): p1 = 'multi_multi_colnames.csv' r = a3.read_table(p1) d = {'atest': ['A1', 'A2'], 'btest': ['B1', 'B2']} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue( e, "table with multiple columns, multiple rows, column names not following letter.string format")
def test_01_read_table_single_col_single_row(self): p1 = 'single_single.csv' r = a3.read_table(p1) d = {'a.test': ['A']} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue(e, "table with one column, one row")
def test_06_read_table_multi_col_no_rows(self): p1 = 'multi_none.csv' r = a3.read_table(p1) d = {'a.test': [], 'b.test': []} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue(e, "table with multiple column, no rows")
def test_04_read_table_multi_col_multi_row(self): p1 = 'multi_multi.csv' r = a3.read_table(p1) d = {'a.test': ['A1', 'A2'], 'b.test': ['B1', 'B2']} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue(e, "table with multiple columns, multiple rows")
def test_05_read_table_single_col_no_rows(self): p1 = 'single_none.csv' r = a3.read_table(p1) d = {'a.test': []} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue(e, "table with one column, no rows")
def test_02_read_table_single_col_multi_row(self): p1 = 'single_multi.csv' r = a3.read_table(p1) d = {'a.test': ['A', 'B']} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue(e, "table with one column, multiple rows")
def test_03_read_table_multi_col_single_row(self): p1 = 'multi_single.csv' r = a3.read_table(p1) d = {'a.test': ['A'], 'b.test': ['B']} e = equiv.equiv_tables(r.get_dict(), d) self.assertTrue(e, "table with multiple columns, single row")
return False value = d[k] if not is_table(value): return False return True # typecheck building simple tables and databases t = Table() assert is_table(t), \ 'Creating an empty table is working incorrectly.' d = Database() assert is_database(d), \ 'Creating an empty database is working incorrectly.' # typecheck the reading.py functions result = reading.read_table('csv_files/books.csv') assert is_table(result), \ 'read_table should return a table; please check the handout \ for the definition of a table.' # typecheck reading.read_database result = reading.read_database() assert is_database(result), \ 'read_database should return a database; please check the handout \ for the definition of a database.' # typecheck the required squeal.py function import squeal d1 = {'a': ['b', 'c']} d2 = {'d': ['e', 'f']} t1 = Table()
return False value = d[k] if not is_table(value): return False return True # typecheck building simple tables and databases t = Table() assert is_table(t), \ 'Creating an empty table is working incorrectly.' d = Database() assert is_database(d), \ 'Creating an empty database is working incorrectly.' # typecheck the reading.py functions result = reading.read_table('books.csv') assert is_table(result), \ 'read_table should return a table; please check the handout \ for the definition of a table.' # typecheck reading.read_database result = reading.read_database() assert is_database(result), \ 'read_database should return a database; please check the handout \ for the definition of a database.' # typecheck the required squeal.py function import squeal d1 = {'a': ['b', 'c']} d2 = {'d': ['e', 'f']} t1 = Table()
def is_database(db): if not isinstance(db, Database): return False d = db.get_dict() if not isinstance(d, dict): return False for k in d: if not isinstance(k, str): return False value = d[k] if not is_table(value): return False return True # typecheck the reading.py functions result = reading.read_table('books.csv') assert is_table(result), \ 'read_table should return a table; please check the handout \ for the definition of a table.' # typecheck reading.read_database result = reading.read_database() assert is_database(result), \ 'read_database should return a database; please check the handout \ for the definition of a database.' # typecheck the required squeal.py function import squeal d1 = {'a': ['b', 'c']} d2 = {'d': ['e', 'f']} t1 = Table()
if not isinstance(d, dict): return False for k in d: if not isinstance(k, str): return False value = d[k] if not is_table(value): return False return True # typecheck the reading.py functions # typecheck reading.read_table result = reading.read_table('games.csv') assert is_table(result), \ 'read_table should return a table; please check the handout \ for the definition of a table.' # typecheck reading.read_database result = reading.read_database() assert is_database(result), \ 'read_database should return a database; please check the handout \ for the definition of a database.' # typecheck the required squeal.py function
if not isinstance(db, Database): return False d = db.get_dict() if not isinstance(d, dict): return False for k in d: if not isinstance(k, str): return False value = d[k] if not is_table(value): return False return True # typecheck the reading.py functions result = reading.read_table("games.csv") assert is_table( result ), "read_table should return a table; please check the handout \ for the definition of a table." # typecheck reading.read_database result = reading.read_database() assert is_database( result ), "read_database should return a database; please check the handout \ for the definition of a database." # typecheck the required squeal.py function import squeal