Skip to content

Commit

Permalink
[MIG] iot_input_oca: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafabarmshory committed Jun 14, 2023
1 parent bfe4802 commit fe0f6ae
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 35 deletions.
5 changes: 3 additions & 2 deletions iot_input_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "IoT Input",
"version": "15.0.1.0.0",
"category": "IoT",
"version": "16.0.1.0.0",
"author": "Creu Blanca, Odoo Community Association (OCA)",
"category": "IoT/iot_input_oca",
"license": "AGPL-3",
"installable": True,
"application": True,
"summary": "IoT Input module",
"depends": ["iot_oca"],
"website": "https://github.com/OCA/iot",
Expand Down
8 changes: 1 addition & 7 deletions iot_input_oca/controller/iot_input_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class CallIot(http.Controller):
)
def call_unauthorized_iot(self, serial, passphrase=False, *args, **kwargs):
request = http.request
if not request.env:
return json.dumps(False)

return json.dumps(
request.env["iot.device.input"]
.sudo()
Expand All @@ -47,9 +46,6 @@ def call_unauthorized_iot_multi_input(
JSON formatted string containing a JSON an array of JSON objects.
"""
request = http.request
if not request.env:
_logger.warning("env not set")
return json.dumps({"status": "error", "message": _("Server Error")})
if not passphrase:
_logger.warning("Passphrase is required")
return json.dumps(
Expand Down Expand Up @@ -93,8 +89,6 @@ def call_unauthorized_iot_multi_input(
)
def check_unauthorized_iot(self, serial, *args, **kwargs):
request = http.request
if not request.env:
return json.dumps(False)
device = (
request.env["iot.device.input"]
.sudo()
Expand Down
24 changes: 0 additions & 24 deletions iot_input_oca/migrations/14.0.1.0.0/post-migration.py

This file was deleted.

8 changes: 8 additions & 0 deletions iot_input_oca/tests/test_iot_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def test_single_controller_archived_device(self):
)
self.assertEqual(res.json()["status"], "error")

def test_multi_controller_archived_device(self):
self.device.write({"active": False})
res = self.url_open(
"/iot/%s/multi_input" % self.serial,
data={"passphrase": self.input_passphrase, "values": self.values},
)
self.assertEqual(res.json()["status"], "error")

def test_multi_input_controller_error_passphrase(self):
res = self.url_open(
"/iot/%s/multi_input" % self.device_identification,
Expand Down
24 changes: 24 additions & 0 deletions iot_input_oca/tests/test_iot_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,27 @@ def test_device_input_calling(self):
self.assertEqual(self.device_input.action_ids.args, str([args]))
self.assertEqual(self.device_input.action_ids.res, str(res))
self.assertEqual(1, self.device_input.action_count)

def test_device_input_calling_with_lang(self):
devices = self._get_devices()
self.assertEqual(devices, self.device_input)
device_input_lang = self.env["iot.device.input"].create(
{
"name": "Input",
"lang": "en_US",
"device_id": self.device.id,
"active": True,
"serial": self.serial + self.serial,
"passphrase": self.passphrase,
"call_model_id": self.env.ref(
"iot_input_oca.model_iot_device_input"
).id,
"call_function": "test_input_device",
}
)
devices = self._get_devices()
self.assertIn(self.device_input, devices)
self.assertIn(device_input_lang, devices)
args = "hello"
res = device_input_lang.call_device(value=args)
self.assertEqual(res, {"status": "ok", "value": args})
5 changes: 3 additions & 2 deletions iot_input_oca/tests/test_iot_multi_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ def setUpClass(cls):
cls.single_input_values = [{"input": cls.address_1, "value": "test"}]
cls.iot = cls.env["iot.device.input"]

def remove_test_multi_input_error_wrong_identification(self):
def test_multi_input_error_wrong_identification(self):
iot = self.iot.get_device(
serial=self.device_identification + self.device_identification,
passphrase=self.passphrase,
)
# device not found -> result is error
self.assertEqual(
iot.call_device(values=self.single_input_values)["status"],
"ko",
"error",
)

def test_multi_input_error_no_inputs(self):
Expand Down
1 change: 1 addition & 0 deletions setup/iot_input_oca/odoo/addons/iot_input_oca
6 changes: 6 additions & 0 deletions setup/iot_input_oca/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,
)

0 comments on commit fe0f6ae

Please sign in to comment.