Exemplo n.º 1
0
    def available_metrics_tuples(self):

        result = set()

        for entry in self.result.values():
            py_.deep_map_values(entry, lambda __, path: result.add(tuple(path)))

        return sorted(result)
Exemplo n.º 2
0
    def available_metrics_tuples(self):

        result = set()

        for entry in self.result.values():
            py_.deep_map_values(entry, lambda __, path: result.add(tuple(path)))

        return sorted(result)
    def get_response(self, options, variables):
        def transform_strings(value):
            if isinstance(value, str):
                value = value.format(**variables)
            return value

        # Replace strings templates if posible
        try:
            options = _.deep_map_values(options, transform_strings)
        except KeyError as error:
            raise MissingVariableError(
                "Unknown variable {error}\n"
                "Available variables are:\n"
                "{variables!r}".format(error=error, variables=variables),
                response=None,
            )

        # Apply the base url if it's not a full url
        if not options["url"].startswith("http"):
            options["url"] = "{}{}".format(self.baseurl, options["url"])

        # Default timeout value
        options.setdefault("timeout", self.timeout)

        return session_request(self.requests_session, **options)
Exemplo n.º 4
0
def test_deep_map_values(case, expected):
    assert _.deep_map_values(*case) == expected