Example #1
0
    def test_cannot_handle_a_request_with_an_invalid_report_type(self):
        # Setup
        self.organisation.members.add(self.user)
        self.organisation.members.add(self.user)
        subscription = JournalAccessSubscriptionFactory.create(organisation=self.organisation)
        now_dt = dt.datetime.now()
        JournalAccessSubscriptionPeriodFactory.create(
            subscription=subscription, start=now_dt - dt.timedelta(days=10), end=now_dt + dt.timedelta(days=8)
        )

        data = self.get_report_request_body(
            start="2016-01-01",
            end="2016-02-01",
            requestor_id=self.organisation.id,
            customer_reference=self.organisation.id,
            report_type="bad",
        )
        request = self.factory.post(
            "/", data=data, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
        )
        # Run
        response = SushiWebServiceView.as_view()(request)
        # Check
        dom = et.fromstring(response.content)
        faultcode = dom.find(".//faultcode")
        assert faultcode.text == "SOAP-ENV:Server"
        faultstring = dom.find(".//faultstring")
        assert faultstring.text == "bad reports are not provided"
Example #2
0
 def test_cannot_handle_a_request_without_a_range(self):
     # Setup
     data = self.get_report_request_body(hide_range=True)
     request = self.factory.post(
         "/", data=data, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
     )
     # Run
     response = SushiWebServiceView.as_view()(request)
     # Check
     dom = et.fromstring(response.content)
     faultcode = dom.find(".//faultcode")
     assert faultcode.text == "SOAP-ENV:Server"
     faultstring = dom.find(".//faultstring")
     assert faultstring.text == "Invalid range"
Example #3
0
 def test_cannot_handle_a_request_with_a_range_containing_invalid_dates(self):
     # Setup
     data_1 = self.get_report_request_body(start="bad", end="2016-01-01")
     request_1 = self.factory.post(
         "/", data=data_1, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
     )
     data_2 = self.get_report_request_body(start="2016-01-01", end="bad")
     request_2 = self.factory.post(
         "/", data=data_2, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
     )
     # Run
     response_1 = SushiWebServiceView.as_view()(request_1)
     response_2 = SushiWebServiceView.as_view()(request_2)
     # Check
     dom_1 = et.fromstring(response_1.content)
     faultcode = dom_1.find(".//faultcode")
     assert faultcode.text == "SOAP-ENV:Server"
     faultstring = dom_1.find(".//faultstring")
     assert faultstring.text == "Invalid range"
     dom_2 = et.fromstring(response_2.content)
     faultcode = dom_2.find(".//faultcode")
     assert faultcode.text == "SOAP-ENV:Server"
     faultstring = dom_2.find(".//faultstring")
     assert faultstring.text == "Invalid range"
Example #4
0
 def test_cannot_handle_a_request_with_an_inexistant_organisation(self):
     # Setup
     data = self.get_report_request_body(
         start="2016-01-01", end="2016-02-01", requestor_id="10011", customer_reference="10011"
     )
     request = self.factory.post(
         "/", data=data, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
     )
     # Run
     response = SushiWebServiceView.as_view()(request)
     # Check
     dom = et.fromstring(response.content)
     faultcode = dom.find(".//faultcode")
     assert faultcode.text == "SOAP-ENV:Server"
     faultstring = dom.find(".//faultstring")
     assert faultstring.text == "Unknown Requestor ID and Customer Reference"
Example #5
0
 def test_cannot_handle_a_request_with_a_requestor_id_that_is_different_fro_the_customer_reference(self):  # noqa
     # Setup
     data = self.get_report_request_body(
         start="2016-01-01", end="2016-02-01", requestor_id="1", customer_reference="2"
     )
     request = self.factory.post(
         "/", data=data, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
     )
     # Run
     response = SushiWebServiceView.as_view()(request)
     # Check
     dom = et.fromstring(response.content)
     faultcode = dom.find(".//faultcode")
     assert faultcode.text == "SOAP-ENV:Server"
     faultstring = dom.find(".//faultstring")
     assert faultstring.text == "Invalid (Requestor ID, Customer reference)"
Example #6
0
 def test_cannot_handle_a_request_with_an_organisation_that_has_no_subscription(self):
     # Setup
     data = self.get_report_request_body(
         start="2016-01-01",
         end="2016-02-01",
         requestor_id=self.organisation.id,
         customer_reference=self.organisation.id,
     )
     request = self.factory.post(
         "/", data=data, content_type="text/xml", **{"HTTP_SOAPACTION": "SushiService:GetReportIn"}
     )
     # Run
     response = SushiWebServiceView.as_view()(request)
     # Check
     dom = et.fromstring(response.content)
     faultcode = dom.find(".//faultcode")
     assert faultcode.text == "SOAP-ENV:Server"
     faultstring = dom.find(".//faultstring")
     assert faultstring.text == "Unable to find a valid subscription for the organisation"