예제 #1
0
    def test_post_access_denied(self, post_mock):
        response = MagicMock(spec=Response)
        response.raise_for_status.side_effect = UserWarning()
        post_mock.return_value = response

        with assert_raises(UserWarning):
            post("-url-", "-data-")
예제 #2
0
    def test_post_with_files(self, open_mock, post_mock):
        open_mock.return_value = "-file-content-"

        post("-url-", "-data-", file_paths=["/fake/file/path"])

        args = post_mock.call_args
        assert_equals(args[1]["data"], {"data": '"-data-"'})
        assert_equals(args[1]["files"], [("path", ("path", "-file-content-", "image/png"))])
예제 #3
0
 def __post(self, project, version, runtime, number_of_findings, result, potential_hits):
     data = {
         "dataset": self.dataset,
         "detector": self.detector.id,
         "project": project.id,
         "version": version.version_id,
         "result": result,
         "runtime": runtime,
         "number_of_findings": number_of_findings,
         "potential_hits": potential_hits
     }
     file_paths = PublishFindingsTask.get_file_paths(potential_hits)
     post(self.__upload_url, data, file_paths=file_paths,
          username=self.review_site_user, password=self.review_site_password)
예제 #4
0
    def test_post_auth(self, post_mock):
        post("-url-", "-data-", username="******", password="******")

        assert_equals(post_mock.call_args[1]["auth"], ("user", "pw"))
예제 #5
0
    def test_post_data(self, post_mock):
        post("-url-", "-data-")

        post_mock.assert_called_with(url="-url-", data='"-data-"')
예제 #6
0
    def test_post_with_auth(self, pass_mock, post_mock):
        pass_mock.return_value = "-password-"

        post("-url-", "-data-", username="******")

        assert_equals(post_mock.call_args[1]["auth"], ("-username-", "-password-"))