Esempio n. 1
0
def test_subtoken_update():
    token = Token("test")
    subtoken1 = token.create_subtoken("subtest1")
    subtoken2 = token.create_subtoken("subtest2")

    subtoken1.update(0.5, "progress made in subtest1")

    assert token.state == TokenState.RUNNING
    assert token.progress == 0.5
    assert token.status == "progress made in subtest1"
    assert subtoken1.state == TokenState.RUNNING
    assert subtoken1.progress == 0.5
    assert subtoken1.status == "progress made in subtest1"
    assert subtoken2.state == TokenState.NOTSTARTED
    assert subtoken2.progress == 0.0
    assert subtoken2.status == "Not started"

    subtoken2.update(0.25, "progress made in subtest2")

    assert token.state == TokenState.RUNNING
    assert token.progress == (0.5 + 0.25) / 2
    assert token.status == "progress made in subtest2"
    assert subtoken1.state == TokenState.RUNNING
    assert subtoken1.progress == 0.5
    assert subtoken1.status == "progress made in subtest1"
    assert subtoken2.state == TokenState.RUNNING
    assert subtoken2.progress == 0.25
    assert subtoken2.status == "progress made in subtest2"
Esempio n. 2
0
def test_token_subtokens():
    token = Token("test")
    subtoken1 = token.create_subtoken("subtest1")
    subtoken2 = token.create_subtoken("subtest2")

    subtokens = token.get_subtokens()
    assert len(subtokens) == 2
    assert subtoken1 in subtokens
    assert subtoken2 in subtokens
Esempio n. 3
0
def test_subtoken_initialize():
    token = Token("test")
    subtoken1 = token.create_subtoken("subtest1")
    subtoken2 = token.create_subtoken("subtest2")

    assert token.name == "test"
    assert token.state == TokenState.NOTSTARTED
    assert token.progress == 0.0
    assert token.status == "Not started"
    assert subtoken1.name == "subtest1"
    assert token.state == TokenState.NOTSTARTED
    assert subtoken1.progress == 0.0
    assert subtoken1.status == "Not started"
    assert subtoken2.name == "subtest2"
    assert token.state == TokenState.NOTSTARTED
    assert subtoken2.progress == 0.0
    assert subtoken2.status == "Not started"
Esempio n. 4
0
def test_token_subtokens_with_category():
    token = Token("test")
    subtoken1 = token.create_subtoken("subtest1", "cat1")
    subtoken2 = token.create_subtoken("subtest2", "cat2")

    subtokens = token.get_subtokens()
    assert len(subtokens) == 2
    assert subtoken1 in subtokens
    assert subtoken2 in subtokens

    subtokens = token.get_subtokens("cat1")
    assert len(subtokens) == 1
    assert subtoken1 in subtokens

    subtokens = token.get_subtokens("cat2")
    assert len(subtokens) == 1
    assert subtoken2 in subtokens