"""Tests for the regex utils library.""" import pytest from users.utils import regex_utils @pytest.mark.parametrize( 'test_input,expected', [('oa', True), ('OA', False), ('ao', False), ('alw', True), ('ALW', False), ('wLa', False)], ) def test_finds_app(test_input, expected): """Test if these apps are valid or not.""" result = regex_utils.is_recognisable_app(test_input) assert result == expected @pytest.mark.parametrize( 'test_input,expected', [ ('oa:123', True), ('OA', False), ('OA:123', False), ('alw:123', True), ('ALW:123', False), ('wLa', False), ('alw::123', False), ], ) def test_finds_user_id(test_input, expected): """Test if these user ids are vaild or not.""" result = regex_utils.is_recognisable_user_id(test_input) assert result == expected def test_handles_no_app(): """Test we can handle a none.""" result = regex_utils.is_recognisable_app(None) assert not result def test_handles_no_user_id(): """Test we can handle user id as none.""" result = regex_utils.is_recognisable_user_id() assert not result