Skip to content

Commit

Permalink
Merge pull request #2432 from bonicim/update-test-query-topic
Browse files Browse the repository at this point in the history
Update test query topic
  • Loading branch information
craig8 authored Sep 26, 2020
2 parents 785416f + 696b55a commit 745eb70
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions volttrontesting/platform/dbutils/test_postgresqlfuncts.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,31 @@ def test_get_agg_topic_map_should_return_dict(get_container_func, ports_config):

@pytest.mark.postgresqlfuncts
@pytest.mark.dbutils
@pytest.mark.parametrize(
"topic_1, topic_2, topic_3, topic_pattern, expected_result",
[
("'football'", "'foobar'", "'xzxzxccx'", "foo", {"football": 1, "foobar": 2}),
("'football'", "'foobar'", "'xzxzxccx'", "ba", {"football": 1, "foobar": 2}),
("'football'", "'foobar'", "'xzxzxccx'", "ccx", {"xzxzxccx": 3}),
("'fotball'", "'foobar'", "'xzxzxccx'", "foo", {"foobar": 2}),
("'football'", "'foooobar'", "'xzxzxccx'", "foooo", {"foooobar": 2}),
(
"'FOOtball'",
"'ABCFOOoXYZ'",
"'XXXfOoOo'",
"foo",
{"FOOtball": 1, "ABCFOOoXYZ": 2, "XXXfOoOo": 3},
),
],
)
def test_query_topics_by_pattern_should_return_matching_results(
get_container_func, ports_config
get_container_func,
ports_config,
topic_1,
topic_2,
topic_3,
topic_pattern,
expected_result,
):
get_container, image = get_container_func

Expand All @@ -626,23 +649,20 @@ def test_query_topics_by_pattern_should_return_matching_results(
port_on_host = ports_config["port_on_host"]
wait_for_connection(container, port_on_host)
create_all_tables(container)

with get_postgresqlfuncts(port_on_host) as postgresqlfuncts:
query = f"""
INSERT INTO {TOPICS_TABLE} (topic_name)
VALUES ('football');
VALUES ({topic_1});
INSERT INTO {TOPICS_TABLE} (topic_name)
VALUES ('foobar');
VALUES ({topic_2});
INSERT INTO {TOPICS_TABLE} (topic_name)
VALUES ('xyzzzzzzzz');
VALUES ({topic_3});
"""
seed_database(container, query)
expected = {"football": 1, "foobar": 2}
topic_pattern = "foo"

actual = postgresqlfuncts.query_topics_by_pattern(topic_pattern)
actual_result = postgresqlfuncts.query_topics_by_pattern(topic_pattern)

assert actual == expected
assert actual_result == expected_result


@pytest.mark.postgresqlfuncts
Expand Down

0 comments on commit 745eb70

Please sign in to comment.