Exemple #1
0
    def test_xq_instantiate_without_expr(self):
        cls = xso_query.Class()

        with contextlib.ExitStack() as stack:
            ContextInstance = stack.enter_context(
                unittest.mock.patch("aioxmpp.xso.query.ContextInstance"))

            result = cls.xq_instantiate()

        ContextInstance.assert_called_with(cls, )

        self.assertEqual(result, ContextInstance())
Exemple #2
0
    def test_xq_instantiate(self):
        expr = unittest.mock.sentinel.expr
        cls = xso_query.Class()

        with contextlib.ExitStack() as stack:
            GetInstances = stack.enter_context(
                unittest.mock.patch("aioxmpp.xso.query.GetInstances"))

            result = cls.xq_instantiate(expr)

        GetInstances.assert_called_with(
            expr,
            cls,
        )

        self.assertEqual(result, GetInstances())
Exemple #3
0
    def test_as_expr_recursively_resolves_lhses(self):
        new_lhs = unittest.mock.sentinel.new_lhs

        cls = xso_query.Class()
        descriptor = xso_query.BoundDescriptor(
            cls,
            unittest.mock.sentinel.descriptor,
            xso_query.GetDescriptor,
        )

        result = xso_query.as_expr(descriptor, lhs=new_lhs)

        self.assertIsInstance(
            result,
            xso_query.GetDescriptor,
        )

        self.assertEqual(
            result.descriptor,
            unittest.mock.sentinel.descriptor,
        )

        self.assertIsInstance(
            result.expr,
            xso_query.GetInstances,
        )

        self.assertEqual(
            result.expr.class_,
            cls,
        )

        self.assertEqual(
            result.expr.expr,
            new_lhs,
        )
Exemple #4
0
 def test_init(self):
     xso_query.Class()