3bb6abbcef
feature/simplify b field chunking * Add chunk_by_exhibit function and unit tests * Refactor preprocess * Updated to run BU primary on entire Exhibit * Makes BU secondary compatible with exhibit chunk mapping * Added unit tests for get_exhibit_chunk * Trimmed TD funcs * Downstream changes to run_top_down * Removed conditional funcs * Merged main into feature/simplify-b-field-chunking * removed conditional funcs import * Merged main into feature/simplify-b-field-chunking * Fixed run_bottom_up_primary arguments * Fixed TD primary input * Fixed grouped keyword mappings * Remove filename tracking until postprocessing * Removed postprocessing for client columns * Removed col-based postprocessing * Merged main into feature/simplify-b-field-chunking * Fixed NoneType * Add docstrings * Updated unit tests for removal of 'Filename' * Updated comments Approved-by: Alex Galarce
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
|
|
from src.preprocessing_funcs import chunk_by_exhibit
|
|
|
|
def test1():
|
|
"""Test non-empty text_dict with empty exhibit_pages."""
|
|
text_dict = {'1': 'This', '2': 'is', '3': 'an', '4': 'exhibit', '5': 'test'}
|
|
exhibit_pages = []
|
|
assert chunk_by_exhibit(text_dict, exhibit_pages) == {'1': '1', '2': '2', '3': '3', '4': '4', '5': '5'}
|
|
|
|
def test2():
|
|
"""Test when exhibit_pages contains some keys that are also in text_dict."""
|
|
text_dict = {'1': 'Welcome', '2': 'to', '3': 'the', '4': 'exhibit'}
|
|
exhibit_pages = ['1', '2', '4']
|
|
expected_output = {'1': '1', '2': '2', '3': '2', '4': '4'}
|
|
assert chunk_by_exhibit(text_dict, exhibit_pages) == expected_output
|
|
|
|
|
|
def test3():
|
|
"""Test multiple exhibit pages with transitions between them."""
|
|
text_dict = {'1': 'Page 1', '2': 'Page 2', '3': 'Page 3', '4': 'Page 4', '5': 'Page 5'}
|
|
exhibit_pages = ['2', '4']
|
|
expected_output = {'1': '0', '2': '2', '3': '2', '4': '4', '5': '4'}
|
|
assert chunk_by_exhibit(text_dict, exhibit_pages) == expected_output
|
|
|
|
|
|
test1()
|
|
|
|
test2()
|
|
|
|
test3()
|
|
|