<commit_before>'''
Created on Oct 23, 2014

@author: nmerket
'''
import os
import json
import unittest
from hpxml_to_hescore import HPXMLtoHEScoreTranslator

thisdir = os.path.dirname(os.path.abspath(__file__))
exampledir = os.path.abspath(os.path.join(thisdir,'..','examples'))

class TestAPIHouses(unittest.TestCase):
    
    def _do_compare(self,filebase):
        xmlfilepath = os.path.join(exampledir,filebase + '.xml')
        jsonfilepath = os.path.join(exampledir,filebase + '.json')
        translator = HPXMLtoHEScoreTranslator(xmlfilepath)
        hescore_trans = translator.hpxml_to_hescore_dict()
        with open(os.path.join(exampledir,jsonfilepath)) as f:
            hescore_truth = json.load(f)
        self.assertEqual(hescore_trans, hescore_truth, '{} not equal'.format(filebase))
        
    def test_house1(self):
        self._do_compare('house1')
    
    def test_house1a(self):
        self._do_compare('house1a')
    
    def test_house2(self):
        self._do_compare('house2')

if __name__ == "__main__":<commit_msg>Adding test house 3 for #6<commit_after>'''
Created on Oct 23, 2014

@author: nmerket
'''
import os
import json
import unittest
from hpxml_to_hescore import HPXMLtoHEScoreTranslator

thisdir = os.path.dirname(os.path.abspath(__file__))
exampledir = os.path.abspath(os.path.join(thisdir,'..','examples'))

class TestAPIHouses(unittest.TestCase):
    
    def _do_compare(self,filebase):
        xmlfilepath = os.path.join(exampledir,filebase + '.xml')
        jsonfilepath = os.path.join(exampledir,filebase + '.json')
        translator = HPXMLtoHEScoreTranslator(xmlfilepath)
        hescore_trans = translator.hpxml_to_hescore_dict()
        with open(os.path.join(exampledir,jsonfilepath)) as f:
            hescore_truth = json.load(f)
        self.assertEqual(hescore_trans, hescore_truth, '{} not equal'.format(filebase))
        
    def test_house1(self):
        self._do_compare('house1')
    
    def test_house1a(self):
        self._do_compare('house1a')
    
    def test_house2(self):
        self._do_compare('house2')
    
    def test_house3(self):
        self._do_compare('house3')

if __name__ == "__main__":
{'fraction_non_alphanumeric': 0.11983471074380166, 'fraction_numerical': 0.012855831037649219, 'mean_word_length': 3.6067653276955602, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '3544926', 'n_tokens_mistral': 772, 'n_tokens_neox': 755, 'n_words': 123}