Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ test_validate_code_types() #48

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion tests/kivy_garden/zbarcam/test_zbarcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from kivy.core.image import Image

from kivy_garden.zbarcam import ZBarCam
from kivy_garden.zbarcam.zbarcam import XZbarDecoder
from kivy_garden.zbarcam.zbarcam import XZbarDecoder, ZBarDecoder

FIXTURE_DIR = os.path.join(
os.path.abspath(
Expand All @@ -22,6 +22,25 @@ def patch_is_usable(implementation, m_is_usable):
f'kivy_garden.zbarcam.zbarcam.{implementation}.is_usable', m_is_usable)


class TestZBarDecoder:
"""Tests the ZBarDecoder "abstract" class."""

def test_validate_code_types(self):
"""
Checks `validate_code_types()` properly relies on
`get_available_code_types()` for valid types.
"""
zbar_decoder = ZBarDecoder()
m_get_available_code_types = mock.Mock(
return_value=["QRCODE", "EAN13", "DATABAR"])
zbar_decoder.get_available_code_types = m_get_available_code_types
code_types = ["QRCODE", "EAN13"]
assert zbar_decoder.validate_code_types(code_types) is None
code_types = ["QRCODE", "EAN13", "DOES_NOT_EXIST"]
with pytest.raises(ValueError, match="Invalid code types"):
zbar_decoder.validate_code_types(code_types)


class TestZBarCam:

def setup_method(self):
Expand Down