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
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
|
|
from src.utils.string_utils import get_exhibit_chunk
|
|
|
|
def test1():
|
|
"""Test non-empty text_dict with empty exhibit_pages."""
|
|
text_dict = {'1': 'This', '2': 'is', '3': 'an', '4': 'exhibit', '5': 'test'}
|
|
exhibit_chunk_mapping = {'1': '1', '2': '2', '3': '3', '4': '4', '5': '5'}
|
|
exhibit_page_num = '4'
|
|
assert get_exhibit_chunk(text_dict, exhibit_chunk_mapping, exhibit_page_num) == 'exhibit'
|
|
|
|
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_chunk_mapping = {'1': '1', '2': '2', '3': '2', '4': '4'}
|
|
exhibit_page_num = '2'
|
|
expected_output = "to\nthe"
|
|
assert get_exhibit_chunk(text_dict, exhibit_chunk_mapping, exhibit_page_num) == 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_chunk_mapping = {'1': '0', '2': '2', '3': '2', '4': '4', '5': '4'}
|
|
exhibit_page_num = '4'
|
|
expected_output = 'Page 4\nPage 5'
|
|
assert get_exhibit_chunk(text_dict, exhibit_chunk_mapping, exhibit_page_num) == expected_output
|
|
|
|
|
|
test1()
|
|
|
|
test2()
|
|
|
|
test3()
|
|
|