def test_generate_search_query(): assert PIHandlerWeb.generate_search_query("SINUSOID") == {"q": "name:SINUSOID"} assert PIHandlerWeb.generate_search_query(r"BA:*.1", datasource="sourcename") == { "q": r"name:BA\:*.1", "scope": "pi:sourcename", } assert PIHandlerWeb.generate_search_query(tag="BA:*.1") == { "q": r"name:BA\:*.1", } assert PIHandlerWeb.generate_search_query(desc="Concentration Reactor 1") == { "q": r"description:Concentration\ Reactor\ 1", } assert PIHandlerWeb.generate_search_query( tag="BA:*.1", desc="Concentration Reactor 1" ) == {"q": r"name:BA\:*.1 AND description:Concentration\ Reactor\ 1"}
def PIHandler(): h = PIHandlerWeb(datasource=SOURCE, verifySSL=verifySSL) h.webidcache["alreadyknowntag"] = "knownwebid" yield h
def test_escape_chars(): assert ( PIHandlerWeb.escape('+-&|(){}[]^"~*:\\') == r"\+\-\&\|\(\)\{\}\[\]\^\"\~*\:\\" )
def PIHandler(): h = PIHandlerWeb(datasource="sourcename") h.webidcache["alreadyknowntag"] = "knownwebid" yield h