# Path: coherence/upnp/core/utils.py
# def means_true(value):
# def generalise_boolean(value):
# def parse_xml(data, encoding="utf-8"):
# def parse_http_response(data):
# def get_ip_address(ifname):
# def get_host_address():
#             def result(r):
#             def fail(f):
# def de_chunk_payload(response):
#     def read_chunk_length():
#     def process(self):
#             def deferred_rendering(r):
#     def startFactory(self):
#     def __init__(self, command, rest, version, headers, data, father):
#     def handleStatus(self, version, code, message):
#     def handleHeader(self, key, value):
#     def handleResponsePart(self, buffer):
#     def __init__(self, host, port, path, reactor=reactor):
#     def getChild(self, path, request):
#     def render(self, request):
#     def resetTarget(self, host, port, path, qs=''):
#     def __init__(self, uri, reactor=reactor):
#     def resetUri (self, uri):
#     def buildProtocol(self, addr):
#     def page(self, page):
# def getPage(url, contextFactory=None, *args, **kwargs):
# def downloadPage(url, file, contextFactory=None, *args, **kwargs):
#     def __init__(self, path, target_size=0, *args):
#     def render(self, request):
#     def __init__(self, file, size, request):
#     def resumeProducing(self):
#     def pauseProducing(self):
#     def stopProducing(self):
#     def utcoffset(self, dt):
#     def tzname(self, dt):
#     def dst(self, dt):
# def datefaker():
#         SIOCGIFADDR = 0x8915
#         SIOCGIFADDR = 0xc0206921
# class Request(server.Request):
# class Site(server.Site):
# class ProxyClient(proxy.ProxyClient):
# class ProxyClientFactory(proxy.ProxyClientFactory):
# class ReverseProxyResource(proxy.ReverseProxyResource):
# class ReverseProxyUriResource(ReverseProxyResource):
# class myHTTPPageGetter(client.HTTPPageGetter):
# class HeaderAwareHTTPClientFactory(client.HTTPClientFactory):
# class BufferFile(static.File):
# class BufferFileTransfer(object):
# class _tz(tzinfo):
# class _CET(_tz):
# class _CEST(_tz):


import os
from twisted.trial import unittest
from twisted.python.filepath import FilePath
from twisted.internet import reactor
from twisted.web import static, server
from twisted.protocols import policies
from coherence.upnp.core import utils

            self.assertIn(header, originalHeaders)
            self.assertEqual(originalHeaders[header], headers[header])

    def test_parse_http_response(self):
        cmd, headers, content = utils.parse_http_response(msearch_response1)
        self.assertEqual(cmd, ['HTTP/1.1', '200', 'OK'])
        self.assertEqual(content, '')
        self.assertEqual(headers, {
            'cache-control': 'max-age=1800',
            'date': 'Mon, 02 Jun 2014 18:04:59 GMT',
            'ext': '',
            'location': 'http://192.168.1.4:9000/plugins/UPnP/MediaServer.xml',
            'server': 'Linux/armv5-linux UPnP/1.0 DLNADOC/1.50 MediaServer/7.3/735',
            'st': 'urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1',
            'usn': 'uuid:DDF542FB-A291-4AD0-A0C5-F7129B9D4422::urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1',
            })

    def test_parse_http_error_response(self):
        "An error response without header fields."""
        response = 'HTTP/1.1 405 Method Not Allowed\r\n'
        cmd, headers, content = utils.parse_http_response(response)
        self.assertEqual(cmd, ['HTTP/1.1', '405', 'Method Not Allowed'])
        self.assertEqual(content, '')
        self.assertEqual(headers, {})

    def test_getPage(self):
        content = '0123456789'
        headers = {'accept-ranges': ['bytes'],
                   'content-length': ['10'],
                   'content-type': ['text/html']}

# Path: coherence/upnp/core/utils.py
# def means_true(value):
# def generalise_boolean(value):
# def parse_xml(data, encoding="utf-8"):
# def parse_http_response(data):
# def get_ip_address(ifname):
# def get_host_address():
#             def result(r):
#             def fail(f):
# def de_chunk_payload(response):
#     def read_chunk_length():
#     def process(self):
#             def deferred_rendering(r):
#     def startFactory(self):
#     def __init__(self, command, rest, version, headers, data, father):
#     def handleStatus(self, version, code, message):
#     def handleHeader(self, key, value):
#     def handleResponsePart(self, buffer):
#     def __init__(self, host, port, path, reactor=reactor):
#     def getChild(self, path, request):
#     def render(self, request):
#     def resetTarget(self, host, port, path, qs=''):
#     def __init__(self, uri, reactor=reactor):
#     def resetUri (self, uri):
#     def buildProtocol(self, addr):
#     def page(self, page):
# def getPage(url, contextFactory=None, *args, **kwargs):
# def downloadPage(url, file, contextFactory=None, *args, **kwargs):
#     def __init__(self, path, target_size=0, *args):
#     def render(self, request):
#     def __init__(self, file, size, request):
#     def resumeProducing(self):
#     def pauseProducing(self):
#     def stopProducing(self):
#     def utcoffset(self, dt):
#     def tzname(self, dt):
#     def dst(self, dt):
# def datefaker():
#         SIOCGIFADDR = 0x8915
#         SIOCGIFADDR = 0xc0206921
# class Request(server.Request):
# class Site(server.Site):
# class ProxyClient(proxy.ProxyClient):
# class ProxyClientFactory(proxy.ProxyClientFactory):
# class ReverseProxyResource(proxy.ReverseProxyResource):
# class ReverseProxyUriResource(ReverseProxyResource):
# class myHTTPPageGetter(client.HTTPPageGetter):
# class HeaderAwareHTTPClientFactory(client.HTTPClientFactory):
# class BufferFile(static.File):
# class BufferFileTransfer(object):
# class _tz(tzinfo):
# class _CET(_tz):
# class _CEST(_tz):


# Path: coherence/upnp/core/test/test_utils.py
import os
from twisted.trial import unittest
from twisted.python.filepath import FilePath
from twisted.internet import reactor
from twisted.web import static, server
from twisted.protocols import policies
from coherence.upnp.core import utils

            self.assertIn(header, originalHeaders)
            self.assertEqual(originalHeaders[header], headers[header])

    def test_parse_http_response(self):
        cmd, headers, content = utils.parse_http_response(msearch_response1)
        self.assertEqual(cmd, ['HTTP/1.1', '200', 'OK'])
        self.assertEqual(content, '')
        self.assertEqual(headers, {
            'cache-control': 'max-age=1800',
            'date': 'Mon, 02 Jun 2014 18:04:59 GMT',
            'ext': '',
            'location': 'http://192.168.1.4:9000/plugins/UPnP/MediaServer.xml',
            'server': 'Linux/armv5-linux UPnP/1.0 DLNADOC/1.50 MediaServer/7.3/735',
            'st': 'urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1',
            'usn': 'uuid:DDF542FB-A291-4AD0-A0C5-F7129B9D4422::urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1',
            })

    def test_parse_http_error_response(self):
        "An error response without header fields."""
        response = 'HTTP/1.1 405 Method Not Allowed\r\n'
        cmd, headers, content = utils.parse_http_response(response)
        self.assertEqual(cmd, ['HTTP/1.1', '405', 'Method Not Allowed'])
        self.assertEqual(content, '')
        self.assertEqual(headers, {})

    def test_getPage(self):
        content = '0123456789'
        headers = {'accept-ranges': ['bytes'],
                   'content-length': ['10'],
                   'content-type': ['text/html']}

        d = utils.getPage(self.getURL("file"))
