Пример #1
0
def test_is_table_answer():
    answer = {
        "answerElements": [{
            "metadata": {
                "columnMetadata": [{
                    "name": "col1",
                    "schema": "List<String>"
                }]
            },
            "rows": [{
                "col1": ["e1", "e2", "e3"]
            }],
        }]
    }
    assert not is_table_ans(answer)
    # Fix up metadata
    answer["answerElements"][0][
        "class"] = "org.batfish.datamodel.table.TableAnswerElement"
    assert is_table_ans(answer)
Пример #2
0
    def get_answer(self, question, snapshot, reference_snapshot=None):
        # type: (str, str, Optional[str]) -> Answer
        """
        Get the answer for a previously asked question.

        :param question: the unique identifier of the previously asked question
        :type question: str
        :param snapshot: name of the snapshot the question was run on
        :type snapshot: str
        :param reference_snapshot: if present, gets the answer for a differential question asked against the specified reference snapshot
        :type reference_snapshot: str
        :return: answer to the specified question
        :rtype: :py:class:`Answer`
        """
        params = {"snapshot": snapshot, "referenceSnapshot": reference_snapshot}
        ans = restv2helper.get_answer(self, question, params)
        if is_table_ans(ans):
            return TableAnswer(ans)
        else:
            return Answer(ans)