Example #1
0
def test_remove_final_completed_location_removes_section():
    completed = [
        {
            "section_id": "s1",
            "list_item_id": None,
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["one"],
        },
        {
            "section_id": "s2",
            "list_item_id": "abc123",
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["three"],
        },
    ]
    store = ProgressStore(completed)

    non_repeating_location = Location(section_id="s1", block_id="one")
    repeating_location = Location(
        section_id="s2", block_id="three", list_name="people", list_item_id="abc123"
    )

    store.remove_completed_location(non_repeating_location)
    store.remove_completed_location(repeating_location)

    assert ("s1", None) not in store
    assert store.get_completed_block_ids(section_id="s1") == []

    assert ("s2", "abc123") not in store
    assert store.get_completed_block_ids(section_id="s1", list_item_id="abc123") == []

    assert store.is_dirty
Example #2
0
def test_remove_non_existent_completed_location():
    completed = [
        {
            "section_id": "s1",
            "list_item_id": None,
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["one"],
        }
    ]
    store = ProgressStore(completed)

    non_repeating_location = Location(section_id="s1", block_id="two")
    repeating_location = Location(
        section_id="s2", block_id="three", list_name="people", list_item_id="abc123"
    )

    store.remove_completed_location(non_repeating_location)
    store.remove_completed_location(repeating_location)

    assert len(store.get_completed_block_ids(section_id="s1")) == 1
    assert not store.is_dirty