Example #1
0
def test_in_progress_and_completed_section_ids(section_ids, expected_section_keys):
    completed = [
        {
            "section_id": "s1",
            "list_item_id": None,
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["one", "two"],
        },
        {
            "section_id": "s2",
            "list_item_id": None,
            "status": CompletionStatus.IN_PROGRESS,
            "block_ids": ["three"],
        },
        {
            "section_id": "s3",
            "list_item_id": "abc123",
            "status": CompletionStatus.NOT_STARTED,
            "block_ids": ["three"],
        },
        {
            "section_id": "s4",
            "list_item_id": "123abc",
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["not-three"],
        },
        {
            "section_id": "s5",
            "list_item_id": "456def",
            "status": CompletionStatus.IN_PROGRESS,
            "block_ids": ["not-three"],
        },
    ]

    store = ProgressStore(completed)

    statuses = {CompletionStatus.COMPLETED, CompletionStatus.IN_PROGRESS}
    section_keys = store.section_keys(section_ids=section_ids, statuses=statuses)

    assert sorted(section_keys) == expected_section_keys
Example #2
0
def test_section_keys():
    completed = [
        {
            "section_id": "s1",
            "list_item_id": None,
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["one", "two"],
        },
        {
            "section_id": "s2",
            "list_item_id": None,
            "status": CompletionStatus.IN_PROGRESS,
            "block_ids": ["three"],
        },
        {
            "section_id": "s3",
            "list_item_id": "abc123",
            "status": CompletionStatus.NOT_STARTED,
            "block_ids": ["three"],
        },
        {
            "section_id": "s4",
            "list_item_id": "123abc",
            "status": CompletionStatus.COMPLETED,
            "block_ids": ["not-three"],
        },
        {
            "section_id": "s5",
            "list_item_id": "456def",
            "status": CompletionStatus.IN_PROGRESS,
            "block_ids": ["not-three"],
        },
    ]

    store = ProgressStore(completed)
    section_keys = store.section_keys(section_ids={"s1", "s2", "s3"})
    assert sorted(section_keys) == sorted(
        [("s1", None), ("s2", None), ("s3", "abc123")]
    )