Skip to content

Commit

Permalink
[IMP] Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edescalona committed Dec 20, 2024
1 parent ed91616 commit d1b930d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stock_barcodes_camera/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import common
from . import test_stock_barcodes
23 changes: 23 additions & 0 deletions stock_barcodes_camera/tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2108-2019 Francois Poizat <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestCommonStockBarcodes(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.location_hash = (
"#id=17&model=wiz.stock.barcodes.read.inventory&view_type=form"
)

def camera_barcode_scanner(self, location_hash=""):
if location_hash:
wiz_stock_id = location_hash.split("id=")[1].split("&")[0]
wiz_model_name = location_hash.split("model=")[1].split("&")[0]
if not wiz_stock_id or not wiz_model_name:
return False

Check warning on line 20 in stock_barcodes_camera/tests/common.py

View check run for this annotation

Codecov / codecov/patch

stock_barcodes_camera/tests/common.py#L20

Added line #L20 was not covered by tests
return True
else:
return False
20 changes: 20 additions & 0 deletions stock_barcodes_camera/tests/test_stock_barcodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2108-2019 Sergio Teruel <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import tagged

from .common import TestCommonStockBarcodes


@tagged("post_install", "-at_install")
class TestStockBarcodes(TestCommonStockBarcodes):
def test_location_hash(self):
valid_hash = self.camera_barcode_scanner(self.location_hash)
self.assertEqual(valid_hash, True)
empty_hash = self.camera_barcode_scanner()
self.assertEqual(empty_hash, False)
with self.assertRaises(IndexError):
invalid_loc_hash = self.location_hash.replace("id=", "idd=")
self.camera_barcode_scanner(invalid_loc_hash)
with self.assertRaises(IndexError):
invalid_loc_hash = self.location_hash.replace("model=", "modell=")
self.camera_barcode_scanner(invalid_loc_hash)

0 comments on commit d1b930d

Please sign in to comment.