Ejemplo n.º 1
0
def test_delete_with_invalid_uuid_fails(setup_teardown):
    uid = "hello world"

    repo = JsonRepo('test')

    with pytest.raises(ValueError):
        repo.delete(uid)
Ejemplo n.º 2
0
def test_delete_non_existant_card_fails(setup_teardown):
    uid = str(uuid.uuid4())

    repo = JsonRepo('test')
    repo.delete(uid)

    with pytest.raises(FileNotFoundError):
        repo.save()
Ejemplo n.º 3
0
def test_delete_deletes(setup_teardown):
    uid = create_and_save_card('test title')

    repo = JsonRepo('test')
    repo.delete(uid)
    repo.save()

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

    assert len(test_repo.cards_in_memory) == 0
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
def delete_card_command(env, card_dict: dict) -> dict:
    uid = card_dict['uid']

    repo = JsonRepo(env)
    repo.delete(uid)
    try:
        repo.save()

    except FileNotFoundError:
        return {
            'message': 'No card with uid "%s" was found in the repo' % uid
        }

    except ValueError:
        return {'message': 'This card has existing children cards, cannot delete'}

    return {
        'message': 'Card deleted',
        'uid': str(uid)
    }
Ejemplo n.º 6
0
def test_delete_mem_empties_on_save(setup_teardown):
    uid = create_and_save_card('test title')
    repo = JsonRepo('test')
    repo.delete(uid)
    repo.save()
    assert len(repo.cards_to_delete) == 0