Ejemplo n.º 1
0
    def test_mount_node_without_identity_produces_item_not_found(self):
        node = disco_service.StaticNode()

        self.s.mount_node("foo", node)

        self.request_iq.payload.node = "foo"
        with self.assertRaises(errors.XMPPModifyError):
            run_coroutine(self.s.handle_info_request(self.request_iq))
Ejemplo n.º 2
0
    def test_unmount_node(self):
        node = disco_service.StaticNode()
        node.register_identity("hierarchy", "leaf")

        self.s.mount_node("foo", node)

        self.s.unmount_node("foo")

        self.request_iq.payload.node = "foo"
        with self.assertRaises(errors.XMPPModifyError):
            run_coroutine(self.s.handle_info_request(self.request_iq))
Ejemplo n.º 3
0
    def test_mount_node_produces_response(self):
        node = disco_service.StaticNode()
        node.register_identity("hierarchy", "leaf")

        self.s.mount_node("foo", node)

        self.request_iq.payload.node = "foo"
        response = run_coroutine(self.s.handle_info_request(self.request_iq))

        self.assertSetEqual({
            ("hierarchy", "leaf", None, None),
        },
                            set((item.category, item.type_, item.name,
                                 item.lang) for item in response.identities))
Ejemplo n.º 4
0
    def test_items_query_returns_items_of_mounted_node(self):
        item1 = disco_xso.Item(TEST_JID.replace(localpart="foo"))
        item2 = disco_xso.Item(TEST_JID.replace(localpart="bar"))

        node = disco_service.StaticNode()
        node.register_identity("hierarchy", "leaf")
        node.items.append(item1)
        node.items.append(item2)

        self.s.mount_node("foo", node)

        self.request_items_iq.payload.node = "foo"
        response = run_coroutine(
            self.s.handle_items_request(self.request_items_iq))

        self.assertSequenceEqual([item1, item2], response.items)
Ejemplo n.º 5
0
 def setUp(self):
     self.n = disco_service.StaticNode()