"""Tests.""" import pytest from participant.utils.convert import escape_term, node_to_dict, to_int def test_node_to_dict(): """Test node_to_dict function.""" data = {'a': 1, 'b': 'two', 'c': False} class Node(dict): """Mock node class for testing node_to_dict function.""" def __init__(self, d): self.data = d def items(self): return self.data n = Node(data) d = node_to_dict(n.items()) assert d == data @pytest.mark.parametrize( ('data', 'expected_result'), [ ('a', 'a'), ('1', 1), ], ) def test_to_int(data, expected_result): """Test to_int function.""" result = to_int(data) assert result == expected_result @pytest.mark.parametrize( ('term', 'expected_result'), [ ('ab!', 'ab\\!'), ('ab*', 'ab\\*'), ], ) def test_escape_term(term, expected_result): """Test escape_term function.""" result = escape_term(term) assert result == expected_result