# Path: tt/definitions/operators.py
# BINARY_OPERATORS = {
#     TT_AND_OP,
#     TT_IMPL_OP,
#     TT_NAND_OP,
#     TT_NOR_OP,
#     TT_OR_OP,
#     TT_XNOR_OP,
#     TT_XOR_OP
# }
# 
# TT_AND_OP = BooleanOperator(_PRECEDENCE['LOW'],
#                             lambda a, b: a and b,
#                             '/\\', 'and')
# 
# TT_OR_OP = BooleanOperator(_PRECEDENCE['ZERO'],
#                            lambda a, b: a or b,
#                            '\\/', 'or')
# 
# Path: tt/tests/unit/trees/_helpers.py
# class ExpressionTreeAndNodeTestCase(unittest.TestCase):
# 
#     def get_tree_root_from_expr_str(self, expr_str):
#         """Get an tree root node from an expression string."""
#         return BooleanExpression(expr_str).tree


from tt.definitions import (
    BINARY_OPERATORS,
    TT_AND_OP,
    TT_OR_OP)
from ._helpers import ExpressionTreeAndNodeTestCase




class TestNodeDistributeOrs(ExpressionTreeAndNodeTestCase):

    def test_single_operand(self):
        """Test that no change occurs for a single operand."""
        root = self.get_tree_root_from_expr_str('A')
        dor = root.distribute_ands()
        self.assertTrue(dor is not root)
        self.assertEqual(
            str(dor),
            'A')

    def test_only_unary_operators(self):
        """Test that no change occurs for expression of only unary NOTs."""
        root = self.get_tree_root_from_expr_str('~A')
        dor = root.distribute_ands()
        self.assertTrue(dor is not root)
        self.assertTrue(dor.l_child is not root.l_child)
        self.assertEqual(
            str(dor),
            '\n'.join((
                '~',
                '`----A')))

    def test_binary_op_no_change_expected(self):
        """Test no change occurs for non-applicable scenarios."""
        # test non-AND and non-OR binary operators

# Path: tt/definitions/operators.py
# BINARY_OPERATORS = {
#     TT_AND_OP,
#     TT_IMPL_OP,
#     TT_NAND_OP,
#     TT_NOR_OP,
#     TT_OR_OP,
#     TT_XNOR_OP,
#     TT_XOR_OP
# }
# 
# TT_AND_OP = BooleanOperator(_PRECEDENCE['LOW'],
#                             lambda a, b: a and b,
#                             '/\\', 'and')
# 
# TT_OR_OP = BooleanOperator(_PRECEDENCE['ZERO'],
#                            lambda a, b: a or b,
#                            '\\/', 'or')
# 
# Path: tt/tests/unit/trees/_helpers.py
# class ExpressionTreeAndNodeTestCase(unittest.TestCase):
# 
#     def get_tree_root_from_expr_str(self, expr_str):
#         """Get an tree root node from an expression string."""
#         return BooleanExpression(expr_str).tree


# Path: tt/tests/unit/trees/test_node_distribute_ands.py
from tt.definitions import (
    BINARY_OPERATORS,
    TT_AND_OP,
    TT_OR_OP)
from ._helpers import ExpressionTreeAndNodeTestCase





class TestNodeDistributeOrs(ExpressionTreeAndNodeTestCase):

    def test_single_operand(self):
        """Test that no change occurs for a single operand."""
        root = self.get_tree_root_from_expr_str('A')
        dor = root.distribute_ands()
        self.assertTrue(dor is not root)
        self.assertEqual(
            str(dor),
            'A')

    def test_only_unary_operators(self):
        """Test that no change occurs for expression of only unary NOTs."""
        root = self.get_tree_root_from_expr_str('~A')
        dor = root.distribute_ands()
        self.assertTrue(dor is not root)
        self.assertTrue(dor.l_child is not root.l_child)
        self.assertEqual(
            str(dor),
            '\n'.join((
                '~',
                '`----A')))

    def test_binary_op_no_change_expected(self):
        """Test no change occurs for non-applicable scenarios."""
        # test non-AND and non-OR binary operators

        for op in (BINARY_OPERATORS - {TT_AND_OP, TT_OR_OP}):