Skip to content

Commit

Permalink
[IMP] pos_customer_screen_partner_location: Test is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
geomer198 committed May 21, 2024
1 parent e9705b3 commit 9d60bfb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pos_customer_screen_partner_location/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from werkzeug.exceptions import BadRequest

from odoo import http
from odoo.http import request

Expand All @@ -11,10 +13,13 @@ class CustomerScreenPartnerLocation(http.Controller):
)
def customer_screen_location(self, partner_id, pos_config_id):
partner = request.env["res.partner"].browse(partner_id)
config = request.env["pos.config"].browse(pos_config_id)
if not (partner.exists() and config.exists()):
raise BadRequest("Partner or POS config is not available")
return request.render(
"pos_customer_screen_partner_location.customer_screen_pos",
{
"partner": partner,
"config_id": pos_config_id,
"config_id": config.id,
},
)
1 change: 1 addition & 0 deletions pos_customer_screen_partner_location/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_customer_screen
45 changes: 45 additions & 0 deletions pos_customer_screen_partner_location/tests/test_customer_screen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests import HttpCase, tagged


@tagged("post_install", "-at_install")
class TestCustomerScreen(HttpCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.partner = cls.env["res.partner"].create({"name": "Test Partner"})
cls.pos_config = cls.env["pos.config"].create({"name": "Test Config"})

def test_customer_screen_location(self):
self.authenticate("admin", "admin")

resp_invalid = self.url_open(
f"/customer_screen_location/0/{self.pos_config.id}/"
)
self.assertFalse(resp_invalid.ok, "Response must not be OK")
self.assertEqual(
resp_invalid.status_code, 400, "Response status code must be equal to 400"
)

resp_invalid = self.url_open(f"/customer_screen_location/{self.partner.id}/0/")
self.assertFalse(resp_invalid.ok, "Response must not be OK")
self.assertEqual(
resp_invalid.status_code, 400, "Response status code must be equal to 400"
)

resp_invalid = self.url_open("/customer_screen_location/0/0/")
self.assertFalse(resp_invalid.ok, "Response must not be OK")
self.assertEqual(
resp_invalid.status_code, 400, "Response status code must be equal to 400"
)

response = self.url_open(
f"/customer_screen_location/{self.partner.id}/{self.pos_config.id}/"
)
self.assertTrue(response.ok, "Response must be OK")
self.assertEqual(
response.status_code, 200, "Response status code must be equal to 200"
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
Location
</h5>
</div>
<div class="card-body partner-map-body" t-ref="map-container" />
<div class="card-body partner-map-body" />
<div class="card-footer" style="display: flex !important;">
<input
class="flex-grow-1 map-addr-input form-control"
name="address"
t-ref="addr-input"
placeholder="Address"
/>
<button class="btn btn-light cancel ">
Expand Down

0 comments on commit 9d60bfb

Please sign in to comment.