<commit_before>from unittest import TestCase

from directory.models import Person
from directory.scraper import (get_person,
                               get_search_inputs,
                               get_results)
from directory.helpers import (search_field_aliases,
                               search_field_full_name,
                               valid_department,
                               valid_person_type)


class PersonTests(TestCase):
    def test_set_key_init(self):
        person = Person(webid='1')
        self.assertEqual(person.webid, '1')

    def test_setter(self):
        person = Person()
        person.webid = '1'
        self.assertEqual(person.webid, '1')

    def test_str(self):
        person = Person(webid='1')
        self.assertEqual(str(person), '<Person 1>')

    def test_repr(self):
        person = Person(webid='1')
        self.assertEqual(repr(person), '<Person 1>')


def HelperTests(TestCase):
    def test_search_field_full_name(self):
        fields = {'ctl00$ctl00$PageContent$PageContent$middDirectoryForm$txtTelephonenumber': ''}  # noqa
        full = search_field_full_name(fields.keys(), 'Telephonenumber')

        self.assertIn(full, fields)

    def test_valid_person_type(self):
        invalid = 'notaperson'
        self.assertFalse(valid_person_type(invalid))

        valid = 'Student'
        self.assertTrue(valid_person_type(valid))

        valid_aliased = 'Summer Graduate'
        self.assertTrue(valid_person_type(valid_aliased))

    def test_valid_department(self):
        valid = 'Russian School'
        self.assertTrue(valid_department(valid))

        invalid = 'Not A Department'
        self.assertFalse(valid_department(invalid))
<commit_msg>That should be a class. Run the helper tests.<commit_after>from unittest import TestCase

from directory.models import Person
from directory.scraper import (get_person,
                               get_search_inputs,
                               get_results)
from directory.helpers import (search_field_aliases,
                               search_field_full_name,
                               valid_department,
                               valid_person_type)


class PersonTests(TestCase):
    def test_set_key_init(self):
        person = Person(webid='1')
        self.assertEqual(person.webid, '1')

    def test_setter(self):
        person = Person()
        person.webid = '1'
        self.assertEqual(person.webid, '1')

    def test_str(self):
        person = Person(webid='1')
        self.assertEqual(str(person), '<Person 1>')

    def test_repr(self):
        person = Person(webid='1')
        self.assertEqual(repr(person), '<Person 1>')


class HelperTests(TestCase):
    def test_search_field_full_name(self):
        fields = {'ctl00$ctl00$PageContent$PageContent$middDirectoryForm$txtTelephonenumber': ''}  # noqa
        full = search_field_full_name(fields.keys(), 'phone')

        self.assertIn(full, fields)

    def test_valid_person_type(self):
        invalid = 'notaperson'
        self.assertFalse(valid_person_type(invalid))

        valid = 'Student'
        self.assertTrue(valid_person_type(valid))

        valid_aliased = 'Summer Graduate'
        self.assertTrue(valid_person_type(valid_aliased))

    def test_valid_department(self):
        valid = 'Russian School'
        self.assertTrue(valid_department(valid))

        invalid = 'Not A Department'
        self.assertFalse(valid_department(invalid))

{'fraction_non_alphanumeric': 0.09701492537313433, 'fraction_numerical': 0.006888633754305396, 'mean_word_length': 2.50956696878147, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6366992', 'n_tokens_mistral': 1021, 'n_tokens_neox': 984, 'n_words': 180}