def test_rearrange_to_columns(): table = Table(TEST_ID) table_data = table.fetch_table(TEST_ID) data = table.parse_table(table_data) header = table.extract_header(data) columns = table.rearrange_to_columns(header, data) assert data == TEST_DATA
def test_get_atomic_table_path(): table = Table(TEST_ID) atomic_tables = atomize(table) atomic_table = atomic_tables[0] _path = get_atomic_table_path(atomic_table, path=ATOMIC_TABLES_DIR) _PATH = os.path.join(ATOMIC_TABLES_DIR, generate_atomic_table_id(atomic_table) + ".table") assert _path == _PATH
def test_dump_atomic_tables(): table = Table(TEST_ID) atomic_tables = atomize(table) atomic_table = atomic_tables[0] _filepath = get_atomic_table_path(atomic_table, path=ATOMIC_TABLES_DIR) dump_atomic_table(atomic_table, path=ATOMIC_TABLES_DIR) #check if file was written to the directory assert os.path.exists(_filepath) #remove the file os.remove(_filepath) assert not os.path.exists(_filepath)
def test_subject_column(): table = Table(TEST_ID) assert table.subject_column == [0]
def test_parse_table(): table = Table(TEST_ID) table_data = table.fetch_table(TEST_ID) data = table.parse_table(table_data) assert data == TEST_DATA
def test_extract_header(): table = Table(TEST_ID) table_data = table.fetch_table(TEST_ID) data = table.parse_table(table_data) header = table.extract_header(data) assert header == TEST_HEADER
def test_fetch_table(): table = Table(TEST_ID) table_data = table.fetch_table(TEST_ID) assert table_data == TEST_TABLE
def test_generate_atomic_table_id(): table = Table(TEST_ID) atomic_tables = atomize(table) atomic_table = atomic_tables[0] _id = generate_atomic_table_id(atomic_table) assert _id == TABLE_ID
def test_atomize(): table = Table(TEST_ID) atomic_tables = atomize(table) assert len(atomic_tables[0]) == 2 assert len(atomic_tables[0][0]) == len(atomic_tables[0][1])
def get_one_table(offset): table_list = get_table_list() offset = offset % len(table_list) return Table(table_list[offset])