Beispiel #1
0
 def test_asjson_required_params(self):
     request = TransformDocumentRequest(
         document=encode_base64("Hello World3!"), service_name="QDS.TEST")
     assert (
         request.json() ==
         '{"document": "SGVsbG8gV29ybGQzIQ==", "service_name": "QDS.TEST", "file_name": null, "options": null}'
     )
Beispiel #2
0
 def test_asjson_required_params(self):
     response = TransformDocumentResponse(
         document=encode_base64("Hello World Response4!"))
     assert (
         response.json() ==
         '{"document": "SGVsbG8gV29ybGQgUmVzcG9uc2U0IQ==", "output": null, "error": null}'
     )
Beispiel #3
0
 def test_asdict_required_params(self):
     response = TransformDocumentResponse(
         document=encode_base64("Hello World Response2!"))
     response_dict = response.dict()
     assert len(response_dict.keys()) == 3
     assert response_dict["document"] == "SGVsbG8gV29ybGQgUmVzcG9uc2UyIQ=="
     assert response_dict["output"] is None
     assert response_dict["error"] is None
Beispiel #4
0
 def test_asdict_required_params(self):
     request = TransformDocumentRequest(
         document=encode_base64("Hello World!"), service_name="QDS.TEST")
     request_dict = request.dict()
     assert len(request_dict.keys()) == 4
     assert request_dict["document"] == "SGVsbG8gV29ybGQh"
     assert request_dict["service_name"] == "QDS.TEST"
     assert request_dict["file_name"] is None
     assert request_dict["options"] is None
Beispiel #5
0
 def test_asjson_all_params(self):
     response = TransformDocumentResponse(
         document=encode_base64("Hello World Response5!"),
         output=["OUTPUT 1", "OUTPUT 2"],
         error=["ERROR 1", "ERROR 2"],
     )
     assert (
         response.json() ==
         '{"document": "SGVsbG8gV29ybGQgUmVzcG9uc2U1IQ==", "output": ["OUTPUT 1", "OUTPUT 2"], "error": ["ERROR 1", "ERROR 2"]}'
     )
Beispiel #6
0
 def test_asjson_all_params(self):
     request = TransformDocumentPipeRequest(
         document=encode_base64("Hello Pipe Request5!"),
         services=[ServiceInfo(name="QDS.MAIL")],
         file_name="sec.txt",
     )
     assert (
         request.json() ==
         '{"document": "SGVsbG8gUGlwZSBSZXF1ZXN0NSE=", "services": [{"name": "QDS.MAIL", "options": null}], "file_name": "sec.txt"}'
     )
Beispiel #7
0
 def test_asjson_required_params(self):
     request = TransformDocumentPipeRequest(
         document=encode_base64("Hello Pipe Request4!"),
         services=[ServiceInfo(name="QDS.CAESER")],
         file_name=None,
     )
     assert (
         request.json() ==
         '{"document": "SGVsbG8gUGlwZSBSZXF1ZXN0NCE=", "services": [{"name": "QDS.CAESER", "options": null}], "file_name": null}'
     )
Beispiel #8
0
 def test_asdict_all_params(self):
     response = TransformDocumentResponse(
         document=encode_base64("Hello World Response3!"),
         output=["OUTPUT 1", "OUTPUT 2"],
         error=["ERROR 1", "ERROR 2"],
     )
     response_dict = response.dict()
     assert len(response_dict.keys()) == 3
     assert response_dict["document"] == "SGVsbG8gV29ybGQgUmVzcG9uc2UzIQ=="
     assert response_dict["output"] == ["OUTPUT 1", "OUTPUT 2"]
     assert response_dict["error"] == ["ERROR 1", "ERROR 2"]
Beispiel #9
0
 def test_asjson_all_params(self):
     request = TransformDocumentRequest(
         document=encode_base64("Hello World4!"),
         service_name="QDS.TEST",
         file_name="file.txt",
         options=self.TempOptions(offset=4),
     )
     assert (
         request.json() ==
         '{"document": "SGVsbG8gV29ybGQ0IQ==", "service_name": "QDS.TEST", "file_name": "file.txt", "options": {"offset": 4}}'
     )
Beispiel #10
0
 def test_asdict_all_params(self):
     request = TransformDocumentPipeRequest(
         document=encode_base64("Hello Pipe Request3!"),
         services=[ServiceInfo(name="QDS.COUNT")],
         file_name="secret.txt",
     )
     request_dict = request.dict()
     assert len(request_dict.keys()) == 3
     assert request_dict["document"] == "SGVsbG8gUGlwZSBSZXF1ZXN0MyE="
     assert request_dict["services"] == [{
         "name": "QDS.COUNT",
         "options": None
     }]
     assert request_dict["file_name"] == "secret.txt"
Beispiel #11
0
 def test_asdict_required_params(self):
     request = TransformDocumentPipeRequest(
         document=encode_base64("Hello Pipe Request2!"),
         services=[ServiceInfo(name="QDS.ECHO")],
         file_name=None,
     )
     request_dict = request.dict()
     assert len(request_dict.keys()) == 3
     assert request_dict["document"] == "SGVsbG8gUGlwZSBSZXF1ZXN0MiE="
     assert request_dict["services"] == [{
         "name": "QDS.ECHO",
         "options": None
     }]
     assert request_dict["file_name"] is None
Beispiel #12
0
 def test_asdict_all_params(self):
     # TODO: pyright issue?
     options = self.TempOptions(offset=8)
     request = TransformDocumentRequest(
         document=encode_base64("Hello World2!"),
         service_name="QDS.TEST",
         file_name="file.txt",
         options=options,
     )
     request_dict = request.dict()
     assert len(request_dict.keys()) == 4
     assert request_dict["document"] == "SGVsbG8gV29ybGQyIQ=="
     assert request_dict["service_name"] == "QDS.TEST"
     assert request_dict["file_name"] == "file.txt"
     assert request_dict["options"] == options.dict()