Пример #1
0
    def add(self, match_rule=None, response_status=200,
            response_body=b'', response_headers={}, times=1):
        """
        Add a new preset to the boss server.
        """
        new_preset = Preset(
            headers=response_headers,
            body=binary_to_ascii(response_body),
            status=response_status,
            rule=match_rule,
            times=times,
        )

        response = self.http('POST', url=self.path, body=new_preset.as_json())
        if response.status != 200:
            raise ConfigurationError(response.read().decode())
        return response
Пример #2
0
    def add(self,
            match_rule='',
            response_status=200,
            response_body=b'',
            response_headers={},
            times=1):
        """
        Add a new preset to the boss server.
        """
        new_preset = Preset(
            headers=response_headers,
            body=binary_to_ascii(response_body),
            status=response_status,
            rule=match_rule,
            times=times,
        )

        response = self.http('POST', url=self.path, body=new_preset.as_json())
        if response.status != 200:
            raise ConfigurationError(response.read().decode())
        return response