<commit_before>"""
Check that Gabble always responds to disco for voice-v1 and video-v1. They have
hard-coded contents, because they only exist for compatibility with
Google Talk, Google Video Chat, and old versions of Gabble.

In particular, if the appropriate capabilities are not enabled (as in this
test), doing disco on the bundles still gives their contents.
"""

import dbus

from twisted.words.xish import xpath, domish

from servicetest import EventPattern, assertEquals
from gabbletest import exec_test
import constants as cs
import ns

def disco_bundle(q, bus, conn, stream, node, features):

    request = """
<iq from='<EMAIL>/resource'
    id='disco1'
    to='<EMAIL>/resource'
    type='get'>
  <query xmlns='""" + ns.DISCO_INFO + """'
         node='""" + node + """'/>
</iq>
"""
    stream.send(request)

    disco_response = q.expect('stream-iq', query_ns=ns.DISCO_INFO,
            iq_id='disco1')
    nodes = xpath.queryForNodes('/iq/query/feature', disco_response.stanza)
    vars = [n["var"] for n in nodes]
    assertEquals(set(features), set(vars))

def run_test(q, bus, conn, stream):
    conn.Connect()
    event_stream = q.expect('stream-presence')

    c_nodes = xpath.queryForNodes('/presence/c', event_stream.stanza)
    assert c_nodes is not None
    assert len(c_nodes) == 1
    node = c_nodes[0].attributes['node']

    disco_bundle(q, bus, conn, stream, node + '#voice-v1',
            set([ns.GOOGLE_FEAT_VOICE]))
    disco_bundle(q, bus, conn, stream, node + '#video-v1',<commit_msg>Building stanzas with string concat makes me sad.<commit_after>"""
Check that Gabble always responds to disco for voice-v1 and video-v1. They have
hard-coded contents, because they only exist for compatibility with
Google Talk, Google Video Chat, and old versions of Gabble.

In particular, if the appropriate capabilities are not enabled (as in this
test), doing disco on the bundles still gives their contents.
"""

import dbus

from twisted.words.xish import xpath, domish

from servicetest import EventPattern, assertEquals
from gabbletest import exec_test, elem, elem_iq
import constants as cs
import ns

def disco_bundle(q, bus, conn, stream, node, features):
    request = \
        elem_iq(stream, 'get', from_='<EMAIL>/resource')(
          elem(ns.DISCO_INFO, 'query', node=node)
        )
    stream.send(request)

    disco_response = q.expect('stream-iq', query_ns=ns.DISCO_INFO,
            iq_id=request['id'])
    nodes = xpath.queryForNodes('/iq/query/feature', disco_response.stanza)
    vars = [n["var"] for n in nodes]
    assertEquals(set(features), set(vars))

def run_test(q, bus, conn, stream):
    conn.Connect()
    event_stream = q.expect('stream-presence')

    c_nodes = xpath.queryForNodes('/presence/c', event_stream.stanza)
    assert c_nodes is not None
    assert len(c_nodes) == 1
    node = c_nodes[0].attributes['node']

    disco_bundle(q, bus, conn, stream, node + '#voice-v1',
            set([ns.GOOGLE_FEAT_VOICE]))
    disco_bundle(q, bus, conn, stream, node + '#video-v1',
{'fraction_non_alphanumeric': 0.1215815485996705, 'fraction_numerical': 0.004612850082372323, 'mean_word_length': 3.8967741935483873, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1993180', 'n_tokens_mistral': 971, 'n_tokens_neox': 961, 'n_words': 295}