def validates()

in libmozdata/phabricator.py [0:0]


    def validates(self):
        """
        Check the input is a unit result compatible with Phabricator
        """
        # Check name
        assert isinstance(self["name"], str), "name should be a string"

        # Check special optional types
        if "duration" in self:
            assert isinstance(
                self["duration"], (float, int)
            ), "Duration should be an int or float"
        if "coverage" in self:
            assert isinstance(self["coverage"], dict), "Coverage should be a dict"
        if "format" in self:
            assert self["format"] in ("text", "remarkup"), "Invalid format value"

        # Check optional strings
        for key in ("namespace", "engine", "path", "details"):
            if key in self:
                assert isinstance(self[key], str), "{} should be a string".format(key)