def test_import_postmortem_fail_ratelimit(self): net = self.entities["net"][0] request = RequestFactory().get("/import/net/{}/ixf/postmortem/".format(net.id)) request.user = self.admin_user response = view_import_net_ixf_postmortem(request, net.id) assert response.status_code == 200 response = view_import_net_ixf_postmortem(request, net.id) assert response.status_code == 400
def test_postmortem_limit(self): ixlan = self.entities["ixlan"][0] net = self.entities["net"][0] r, netixlans, netixlans_deleted, log = self.ixf_importer.update(ixlan, data=self.json_data) request = RequestFactory().get("/import/net/{}/ixf/postmortem/".format(net.id),{"limit":1}) request.user = self.admin_user response = view_import_net_ixf_postmortem(request, net.id) content = json.loads(response.content) assert len(content["data"]) == 1
def test_postmortem_limit_max(self): ixlan = self.entities["ixlan"][0] net = self.entities["net"][0] r, netixlans, netixlans_deleted, log = self.ixf_importer.update(ixlan, data=self.json_data) request = RequestFactory().get("/import/net/{}/ixf/postmortem/".format(net.id),{"limit":1000}) request.user = self.admin_user response = view_import_net_ixf_postmortem(request, net.id) content = json.loads(response.content) assert len(content["data"]) == 6 assert content["non_field_errors"] == ["Postmortem length cannot exceed 250 entries"]
def test_postmortem(self): ixlan = self.entities["ixlan"][0] net = self.entities["net"][0] r, netixlans, netixlans_deleted, log = self.ixf_importer.update(ixlan, data=self.json_data) request = RequestFactory().get("/import/net/{}/ixf/preview/".format(net.id)) request.user = self.admin_user response = view_import_net_ixf_postmortem(request, net.id) assert response.status_code == 200 content = json.loads(response.content) for entry in content["data"]: del entry["created"] self.assertLog(content, "postmortem_01")