<commit_before>import calendar
import json
import time
import unittest
import urllib
from urlparse import urlparse, urlunparse

from django.conf import settings
import requests
import websocket

import postcodeinfo


def unix_timestamp():
    return calendar.timegm(time.gmtime())


class SmokeTests(unittest.TestCase):

    def test_can_access_backend(self):
        "access the backend"
        response = requests.get(settings.BACKEND_BASE_URI + '/status.json')

    def test_can_access_geocoder(self):
        "lookup a postcode with PostcodeInfo"
        client = postcodeinfo.Client()
        postcode = client.lookup_postcode('SW1A 1AA')
        self.assertEqual(postcode.normalised, 'sw1a1aa')

    def test_can_access_socketserver(self):
        "connect to socket server"

        parts = urlparse(settings.SOCKETIO_SERVER_URL)
        host, _, port = parts.netloc.partition(':')
        host = host or settings.SITE_HOSTNAME
        port = ':%s' % port if port else ''
        path = parts.path + '/1/'
        parts = list(parts)
        protocol = 'https' if settings.SESSION_COOKIE_SECURE else 'http'
        origin = '{protocol}://{host}'.format(
            protocol=protocol,
            host=host
        )
        headers = {
            'Origin': origin,
        }
<commit_msg>Replace address lookup smoketest<commit_after>import calendar
import json
import time
import unittest
import urllib
from urlparse import urlparse, urlunparse

import requests
import websocket
from django.conf import settings
from cla_common.address_lookup.ordnance_survey import AddressLookup


def unix_timestamp():
    return calendar.timegm(time.gmtime())


class SmokeTests(unittest.TestCase):

    def test_can_access_backend(self):
        "access the backend"
        response = requests.get(settings.BACKEND_BASE_URI + '/status.json')

    def test_can_lookup_postcode(self):
        """Lookup a postcode with OS Places"""
        postcode_to_lookup = 'SW1A 1AA'
        key = settings.OS_PLACES_API_KEY
        addresses = AddressLookup(key=key).by_postcode(postcode_to_lookup)
        self.assertGreater(len(addresses), 0)
        result_postcode = addresses[0].get('DPA', {}).get('POSTCODE')
        self.assertEqual(result_postcode, postcode_to_lookup)

    def test_can_access_socketserver(self):
        "connect to socket server"

        parts = urlparse(settings.SOCKETIO_SERVER_URL)
        host, _, port = parts.netloc.partition(':')
        host = host or settings.SITE_HOSTNAME
        port = ':%s' % port if port else ''
        path = parts.path + '/1/'
        parts = list(parts)
        protocol = 'https' if settings.SESSION_COOKIE_SECURE else 'http'
        origin = '{protocol}://{host}'.format(
            protocol=protocol,
            host=host
        )
        headers = {
            'Origin': origin,
        }

{'fraction_non_alphanumeric': 0.09595782073813708, 'fraction_numerical': 0.0035149384885764497, 'mean_word_length': 2.9255172413793105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5516432', 'n_tokens_mistral': 848, 'n_tokens_neox': 830, 'n_words': 197}