Skip to content

Commit

Permalink
fix test, auth partner
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu.saison committed Sep 11, 2023
1 parent cc07cce commit 69e6a6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 6 additions & 0 deletions setup/shopinvader_api_lead/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
19 changes: 7 additions & 12 deletions shopinvader_api_lead/tests/test_shopinvader_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from fastapi import status
from requests import Response

from odoo.tests.common import tagged
from odoo import models
from odoo.tests.common import tagged

from odoo.addons.extendable_fastapi.tests.common import FastAPITransactionCase

from ..routers.lead import leads_router


@tagged("post_install", "-at_install")
class TestShopinvaderLeadsApi(FastAPITransactionCase):
@classmethod
Expand All @@ -27,10 +28,10 @@ def setUpClass(cls) -> None:
"zip": "1410",
"city": "Waterloo",
"country_id": cls.env.ref("base.be").id,
"email": "[email protected]"
"email": "[email protected]",
}
)

cls.default_fastapi_authenticated_partner = cls.env["res.partner"]
cls.default_fastapi_router = leads_router

def test_create_lead(self):
Expand All @@ -53,11 +54,8 @@ def test_create_lead(self):
"email_from": check_data.pop("email"),
}
)
import pdb; pdb.set_trace()
with self._create_test_client() as test_client:
response: Response = test_client.post(
"/leads", content=json.dumps(data)
)
response: Response = test_client.post("/leads", content=json.dumps(data))
self.assertEqual(
response.status_code,
status.HTTP_201_CREATED,
Expand All @@ -74,17 +72,14 @@ def test_create_lead(self):
# self._check_notification("lead_confirmation", lead)

def test_create_lead_with_logged_partner(self):
self.default_fastapi_authenticated_partner = self.test_partner

data = {
"name": "Besoin d'un nouveau site",
"description": "Help, on ne supporte plus magento",
"email": "[email protected]",
}
with self._create_test_client() as test_client:
response: Response = test_client.post(
"/leads", content=json.dumps(data)
)
with self._create_test_client(partner=self.test_partner) as test_client:
response: Response = test_client.post("/leads", content=json.dumps(data))
self.assertEqual(
response.status_code,
status.HTTP_201_CREATED,
Expand Down

0 comments on commit 69e6a6f

Please sign in to comment.