コード例 #1
0
    def get(self, relative_url, fail_on_bad_code=True):
        with app.test_client() as http_client:
            r = http_client.get(**self.request(relative_url))

        if fail_on_bad_code and r.status_code >= 400:
            raise AssertionError("Call to %s returned %s : %s" % (relative_url, r.status_code, r.data))
        return json.loads(r.data)
コード例 #2
0
ファイル: configured_test_case.py プロジェクト: mat128/netman
    def setUp(self):
        if self.switch_specs is not None:
            specs = type(self).switch_specs
        else:
            specs = next(s for s in available_models if s["model"] == self._dev_sample)

        self.switch_hostname = specs["hostname"]
        self.switch_port = specs["port"]
        self.switch_type = specs["model"]
        self.switch_username = specs["username"]
        self.switch_password = specs["password"]
        self.test_port = specs["test_port_name"]
        self.test_ports = specs["ports"]
        self.test_vrrp_track_id = specs.get("test_vrrp_track_id")

        self.remote_switch = RemoteSwitch(SwitchDescriptor(
            netman_server='', **sub_dict(
                specs, 'hostname', 'port', 'model', 'username', 'password')))
        self.remote_switch.requests = FlaskRequest(app.test_client())

        self.client = ValidatingCachedSwitch(self.remote_switch)
        self.try_to = ExceptionIgnoringProxy(self.client, [NotImplementedError])
        self.janitor = ExceptionIgnoringProxy(self.client, [NotImplementedError, NetmanException])

        self.client.connect()
        self.client.start_transaction()
コード例 #3
0
    def setUp(self):
        if self.switch_specs is not None:
            specs = type(self).switch_specs
        else:
            specs = next(s for s in available_models if s["switch_descriptor"].model == self._dev_sample)

        self.switch_descriptor = specs["switch_descriptor"]
        self.test_port = specs["test_port_name"]
        self.test_ports = specs["ports"]
        self.test_vrrp_track_id = specs.get("test_vrrp_track_id")

        self.switch_descriptor.netman_server = ''
        self.remote_switch = RemoteSwitch(self.switch_descriptor)
        self.remote_switch.requests = FlaskRequest(app.test_client())

        self.client = ValidatingCachedSwitch(self.remote_switch)
        self.try_to = ExceptionIgnoringProxy(self.client, [NotImplementedError])
        self.janitor = ExceptionIgnoringProxy(self.client, [NotImplementedError, NetmanException])

        self.client.connect()
        self.client.start_transaction()
コード例 #4
0
    def setUp(self):
        if self.switch_specs is not None:
            specs = type(self).switch_specs
        else:
            specs = next(s for s in available_models
                         if s["switch_descriptor"].model == self._dev_sample)

        self.switch_descriptor = specs["switch_descriptor"]
        self.test_port = specs["test_port_name"]
        self.test_ports = specs["ports"]
        self.test_vrrp_track_id = specs.get("test_vrrp_track_id")

        self.switch_descriptor.netman_server = ''
        self.remote_switch = RemoteSwitch(self.switch_descriptor)
        self.remote_switch.requests = FlaskRequest(app.test_client())

        self.client = ValidatingCachedSwitch(self.remote_switch)
        self.try_to = ExceptionIgnoringProxy(self.client,
                                             [NotImplementedError])
        self.janitor = ExceptionIgnoringProxy(
            self.client, [NotImplementedError, NetmanException])

        self.client.connect()
        self.client.start_transaction()
コード例 #5
0
 def put(self, relative_url, data=None, raw_data=None, fail_on_bad_code=True):
     with app.test_client() as http_client:
         r = http_client.put(data=raw_or_json(raw_data, data), **self.request(relative_url))
     if fail_on_bad_code and r.status_code >= 400:
         raise AssertionError("Call to %s returned %s : %s" % (relative_url, r.status_code, r.data))
     return r