示例#1
0
def test_rename_query(query, database):
    QueryCli.add(query.identifier, database.identifier, query.query)
    new_identifier = str(uuid.uuid4())

    QueryCli.rename(query.identifier, new_identifier)
    assert len(settings.queries) == 1

    renamed_query = settings.queries[new_identifier]
    assert renamed_query.identifier == new_identifier
    assert renamed_query.query == query.query
    assert renamed_query.database.identifier == query.database.identifier
示例#2
0
def test_rename_query_duplicated(query, database):
    other_identifier = str(uuid.uuid4())
    other_query = Query(other_identifier, database, query.query)

    QueryCli.add(query.identifier, database.identifier, query.query)
    QueryCli.add(other_query.identifier, database.identifier,
                 other_query.query)
    assert len(settings.queries) == 2

    with pytest.raises(ValueError):
        QueryCli.rename(query.identifier, other_identifier)
示例#3
0
def test_run_query_not_existing(query):
    with pytest.raises(ValueError):
        QueryCli.run(query.identifier)
示例#4
0
def test_run_query(monkeypatch, query, database):
    monkeypatch.setattr('dbtrigger.core.abstract.Runner.run', lambda _: [])
    QueryCli.add(query.identifier, database.identifier, query.query)
    QueryCli.run(query.identifier)
示例#5
0
def test_rename_query_not_existing(query):
    new_identifier = str(uuid.uuid4())
    with pytest.raises(ValueError):
        QueryCli.rename(query.identifier, new_identifier)
示例#6
0
def test_delete_query(query, database):
    QueryCli.add(query.identifier, database.identifier, query.query)
    QueryCli.delete(query.identifier)
    assert len(settings.queries) == 0
示例#7
0
def test_delete_query_not_existing(query, database):
    QueryCli.add(query.identifier, database.identifier, query.query)
    QueryCli.delete(query.identifier)
    with pytest.raises(ValueError):
        QueryCli.delete(query.identifier)
示例#8
0
def test_add_query_not_existing_database(query):
    with pytest.raises(ValueError):
        QueryCli.add(query.identifier, str(uuid.uuid4()), query.query)
    assert len(settings.queries) == 0
示例#9
0
def test_add_query_duplicate(query, database):
    QueryCli.add(query.identifier, database.identifier, query.query)
    with pytest.raises(ValueError):
        QueryCli.add(query.identifier, database.identifier, query.query)
    assert len(settings.queries) == 1
示例#10
0
def add_query(query, database):
    assert len(settings.queries) == 0
    QueryCli.add(query.identifier, database.identifier, query.query)
    assert len(settings.queries) == 1
示例#11
0
def test_list_no_queries():
    QueryCli.list()
示例#12
0
def test_list(query, database):
    QueryCli.add(query.identifier, database.identifier, query.query)
    QueryCli.list()