# Path: ebill_paynet/components/api.py
# class PayNetDWS:
#     """PayNet DWS web services."""
# 
#     def __init__(self, url, test_service):
#         settings = zeep.Settings(xml_huge_tree=True)
#         session = requests.Session()
#         if test_service:
#             session.verify = SSL_TEST_CERTIFICATE
#         else:
#             session.verify = SSL_PROD_CERTIFICATE
#         transport = zeep.transports.Transport(session=session)
#         self.client = zeep.Client(WSDL_DOC, transport=transport, settings=settings)
#         if url:
#             self.service = self.client.create_service(
#                 "{http://www.sap.com/DWS}DWSBinding", url
#             )
#         else:
#             self.service = self.client.service
# 
#     @staticmethod
#     def authorization(userid, password):
#         """Generate Authorization node."""
#         return {"UserName": userid, "Password": password}
# 
#     @staticmethod
#     def handle_fault(fault):
#         msg = ("{}\n" "code: {} -> {}\n" "actor: {}\n" "detail: {}\n").format(
#             fault.message.upper(),
#             fault.code,
#             fault.subcodes,
#             fault.actor,
#             html.tostring(fault.detail),
#         )
#         _logger.info("Paynet DWS fault : {}".format(msg))
#         return msg
# 
# Path: ebill_paynet/tests/common.py
# class CommonCase(SavepointCase, XmlTestMixin):
#     def setUpClass(cls):
#     def compare_xml_line_by_line(content, expected):
# def get_recorder(base_path=None, **kw):


import os
from odoo.tests.common import SingleTransactionCase
from ..components.api import PayNetDWS
from .common import recorder
                        0,
                        0,
                        {
                            "account_id": cls.account.id,
                            "product_id": cls.product.product_variant_ids[:1].id,
                            "name": "Product 1",
                            "quantity": 1.0,
                            "price_unit": 100.00,
                        },
                    )
                ],
            }
        )

    @recorder.use_cassette
    def test_ping_service(self):
        """Check the ping service testing purpose only."""
        self.dws.service.ping()

    @recorder.use_cassette
    def test_takeShipment(self):
        """Check sending a file to the service."""
        attachment = self.env["ir.attachment"].create(
            {"datas": "bWlncmF0aW9uIHRlc3Q=", "name": "SampleDoc.doc"}
        )
        shipment_id = self.paynet.take_shipment(attachment[0].datas.decode())
        self.assertTrue(shipment_id.startswith("SC"))
        # The shipment is not found on the server ?
        # self.paynet.get_shipment_content(shipment_id)


# Path: ebill_paynet/components/api.py
# class PayNetDWS:
#     """PayNet DWS web services."""
# 
#     def __init__(self, url, test_service):
#         settings = zeep.Settings(xml_huge_tree=True)
#         session = requests.Session()
#         if test_service:
#             session.verify = SSL_TEST_CERTIFICATE
#         else:
#             session.verify = SSL_PROD_CERTIFICATE
#         transport = zeep.transports.Transport(session=session)
#         self.client = zeep.Client(WSDL_DOC, transport=transport, settings=settings)
#         if url:
#             self.service = self.client.create_service(
#                 "{http://www.sap.com/DWS}DWSBinding", url
#             )
#         else:
#             self.service = self.client.service
# 
#     @staticmethod
#     def authorization(userid, password):
#         """Generate Authorization node."""
#         return {"UserName": userid, "Password": password}
# 
#     @staticmethod
#     def handle_fault(fault):
#         msg = ("{}\n" "code: {} -> {}\n" "actor: {}\n" "detail: {}\n").format(
#             fault.message.upper(),
#             fault.code,
#             fault.subcodes,
#             fault.actor,
#             html.tostring(fault.detail),
#         )
#         _logger.info("Paynet DWS fault : {}".format(msg))
#         return msg
# 
# Path: ebill_paynet/tests/common.py
# class CommonCase(SavepointCase, XmlTestMixin):
#     def setUpClass(cls):
#     def compare_xml_line_by_line(content, expected):
# def get_recorder(base_path=None, **kw):


# Path: ebill_paynet/tests/test_ebill_paynet.py
import os
from odoo.tests.common import SingleTransactionCase
from ..components.api import PayNetDWS
from .common import recorder

                        0,
                        0,
                        {
                            "account_id": cls.account.id,
                            "product_id": cls.product.product_variant_ids[:1].id,
                            "name": "Product 1",
                            "quantity": 1.0,
                            "price_unit": 100.00,
                        },
                    )
                ],
            }
        )

    @recorder.use_cassette
    def test_ping_service(self):
        """Check the ping service testing purpose only."""
        self.dws.service.ping()

    @recorder.use_cassette
    def test_takeShipment(self):
        """Check sending a file to the service."""
        attachment = self.env["ir.attachment"].create(
            {"datas": "bWlncmF0aW9uIHRlc3Q=", "name": "SampleDoc.doc"}
        )
        shipment_id = self.paynet.take_shipment(attachment[0].datas.decode())
        self.assertTrue(shipment_id.startswith("SC"))
        # The shipment is not found on the server ?
        # self.paynet.get_shipment_content(shipment_id)


    @recorder.use_cassette