예제 #1
0
def test_card_create_with_parent():
    card1 = Card()
    card2 = Card()

    card1.assign_parent(card2)

    assert card1.parent == card2.uid
예제 #2
0
def test_cant_delete_card_with_children(setup_teardown):
    card1 = Card()
    card2 = Card()

    card2.assign_parent(card1)

    repo = JsonRepo('test')
    repo.add(card1)
    repo.add(card2)
    repo.save()

    uid = str(card1.uid)
    repo.delete(uid)

    with pytest.raises(Exception):
        repo.save()
예제 #3
0
def test_card_to_dict():
    card = Card()
    card2 = Card()
    card.title = 'test title'
    card.edit_text('hello world')
    card.assign_parent(card2)

    dic = card.to_dict()
    expected = {
        'uid': str(card.uid),
        'text_exceeds_500': False,
        'title': card.title,
        'text': card.text,
        'parent': str(card.parent),
    }

    assert dic == expected
예제 #4
0
def test_repo_load_multi_card(setup_teardown):
    repo = JsonRepo('test')
    card = Card()
    card.text = 'hello world'
    card.title = 'test title'
    card2 = Card()
    card.assign_parent(card2)

    repo.add(card)
    repo.add(card2)

    repo.save()

    new_repo = JsonRepo('test')
    new_repo.load()

    assert len(new_repo.cards_in_memory) == 2
예제 #5
0
def test_load_repo(setup_teardown):
    repo = JsonRepo('test')
    card = Card()
    card.edit_text('hello world')
    card.title = 'test title'
    card2 = Card()
    card.assign_parent(card2)

    repo.add(card)
    repo.save()

    new_repo = JsonRepo('test')
    new_repo.load()

    assert len(new_repo.cards_in_memory) == 1

    assert new_repo.cards_in_memory[0] == card