File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
tests/kivy_garden/zbarcam Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 66from kivy .core .image import Image
77
88from kivy_garden .zbarcam import ZBarCam
9- from kivy_garden .zbarcam .zbarcam import XZbarDecoder
9+ from kivy_garden .zbarcam .zbarcam import XZbarDecoder , ZBarDecoder
1010
1111FIXTURE_DIR = os .path .join (
1212 os .path .abspath (
@@ -22,6 +22,25 @@ def patch_is_usable(implementation, m_is_usable):
2222 f'kivy_garden.zbarcam.zbarcam.{ implementation } .is_usable' , m_is_usable )
2323
2424
25+ class TestZBarDecoder :
26+ """Tests the ZBarDecoder "abstract" class."""
27+
28+ def test_validate_code_types (self ):
29+ """
30+ Checks `validate_code_types()` properly relies on
31+ `get_available_code_types()` for valid types.
32+ """
33+ zbar_decoder = ZBarDecoder ()
34+ m_get_available_code_types = mock .Mock (
35+ return_value = ["QRCODE" , "EAN13" , "DATABAR" ])
36+ zbar_decoder .get_available_code_types = m_get_available_code_types
37+ code_types = ["QRCODE" , "EAN13" ]
38+ assert zbar_decoder .validate_code_types (code_types ) is None
39+ code_types = ["QRCODE" , "EAN13" , "DOES_NOT_EXIST" ]
40+ with pytest .raises (ValueError , match = "Invalid code types" ):
41+ zbar_decoder .validate_code_types (code_types )
42+
43+
2544class TestZBarCam :
2645
2746 def setup_method (self ):
You can’t perform that action at this time.
0 commit comments