<commit_before>from django.test import TestCase
import json

def float_equals(a, b):
  return abs(a - b) < 0.00001

class HutResourceTestCase(TestCase):
  fixtures = ['test_data.json']
  url = '/huts/api/v1/hut/'

  def test_query_bbox(self):
    response = self.client.get(self.url + '?bbox=47.05814,-122.79683,49.05814,-120.79683')
    results = json.loads(response.content)
    self.assertEqual(10, results['meta']['total_count'])

  def test_query_bbox_across_180th_meridian(self):<commit_msg>Added hack to ensure 'distance' function in mysql.<commit_after>from django.conf import settings
from django.test import TestCase
import json
import subprocess

def float_equals(a, b):
  return abs(a - b) < 0.00001

class HutResourceTestCase(TestCase):
  fixtures = ['test_data.json']
  url = '/huts/api/v1/hut/'

  @classmethod
  def setUpClass(cls):
    # TODO: this is a hack
    # Create the 'distance' function in mysql
    cmd = ["mysql -u {user} -p'{passw}' < /etc/mysql/hutmap_fns.sql".format( 
             user=settings.DATABASES['default']['USER'],
             passw=settings.DATABASES['default']['PASSWORD'])]
    subprocess.check_call(cmd, shell=True)
    print("Added 'distance' function to mysql")

  def test_query_bbox(self):
    response = self.client.get(self.url + '?bbox=47.05814,-122.79683,49.05814,-120.79683')
    results = json.loads(response.content)
    self.assertEqual(10, results['meta']['total_count'])

  def test_query_bbox_across_180th_meridian(self):
{'fraction_non_alphanumeric': 0.14295347269049224, 'fraction_numerical': 0.056641942009440324, 'mean_word_length': 4.35740072202166, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5272531', 'n_tokens_mistral': 570, 'n_tokens_neox': 509, 'n_words': 101}