<commit_before>import unittest
import context
from mockingbird import Mockingbird
from mockingbird.generators import MockRealName
from mockingbird.generators import MockString
from mockingbird.generators import MockPhoneNumber
from mockingbird.generators import MockEmail
from mockingbird.generators import MockDate
from mockingbird.generators import MockInt
from mockingbird.generators import MockBoolean
from mockingbird.generators import MockChoice
from mockingbird.generators import MockObject
from mockingbird.generators import MockObjectList

from models import Contact
from models import ContactMeta
from models import AddressBook

class MockingbirdSuite(unittest.TestCase):

    def setUp(self):
        self.mockingbird = Mockingbird()

    def test_spec_key(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact, {})
        data = mockingbird["Contact"]()
        self.assertIsInstance(data, Contact)

    def test_spec_attr(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact, {})
        data = mockingbird.Contact()
        self.assertIsInstance(data, Contact)
            

    def test_realname_string(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact, {"name": MockRealName(),
                                   "label": MockString(min=4, max=10)})

        contact = mockingbird.Contact()

        self.assertIsInstance(contact, Contact)
        self.assertIsNotNone(contact.name)
        self.assertIsNotNone(contact.label)
        self.assertGreater(len(contact.name), 1)
        self.assertGreater(len(contact.label), 1)

    def test_nested(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact,     {"name": MockRealName(),
                                       "label": MockString(min=4, max=10),
                                       "meta": MockObject(ContactMeta)})

        mockingbird.spec(ContactMeta, {"phone": MockPhoneNumber(),
                                       "email": MockEmail(),
                                       "dob": MockDate(),
                                       "age": MockInt(min=22, max=44),
                                       "is_married": MockBoolean()})

        contact = mockingbird.Contact()
        meta = contact.meta
        

        self.assertIsNotNone(contact)
        self.assertIsInstance(contact, Contact)
        self.assertIsNotNone(contact.name)
        self.assertIsNotNone(contact.label)
        self.assertTrue(len(contact.name) > 1)
        self.assertTrue(len(contact.label) > 1)

        self.assertIsNotNone(meta)
        self.assertIsInstance(meta, ContactMeta)
        self.assertIsNotNone(meta.phone)
        self.assertIsNotNone(meta.email)
        self.assertIsNotNone(meta.dob)
        self.assertIsNotNone(meta.age)
        self.assertIsNotNone(meta.is_married)

        self.assertTrue(len(meta.phone) > 1)
        self.assertTrue(len(meta.email) > 1)
        self.assertTrue(len(meta.dob) > 1)
        self.assertTrue(meta.age >= 22 and meta.age <= 44)
        self.assertTrue(type(meta.is_married) == bool)

    def test_list_count(self):
        mockingbird = self.mockingbird

        mockingbird.spec(Contact,     {"name": MockRealName(),
                                       "label": MockString(min=4, max=10),
                                       "meta": MockObject(ContactMeta)})

        mockingbird.spec(ContactMeta, {"phone": MockPhoneNumber(),
                                       "email": MockEmail(),
                                       "dob": MockDate(),
                                       "age": MockInt(min=22, max=44),
                                       "is_married": MockBoolean()})

        mockingbird.spec(AddressBook, {"contacts": MockObjectList(Contact, count=5)})

        address_book = mockingbird.AddressBook()
        
        
        self.assertIsNotNone(address_book)
        self.assertIsInstance(address_book, AddressBook)
        self.assertEquals(len(address_book.contacts), 5)

        for contact in address_book.contacts:
            meta = contact.meta

            self.assertIsNotNone(contact)
            self.assertIsInstance(contact, Contact)
            self.assertIsNotNone(contact.name)
            self.assertIsNotNone(contact.label)
            self.assertTrue(len(contact.name) > 1)
            self.assertTrue(len(contact.label) > 1)

            self.assertIsNotNone(meta)
            self.assertIsInstance(meta, ContactMeta)
            self.assertIsNotNone(meta.phone)
            self.assertIsNotNone(meta.email)
            self.assertIsNotNone(meta.dob)
            self.assertIsNotNone(meta.age)
            self.assertIsNotNone(meta.is_married)

            self.assertTrue(len(meta.phone) > 1)
            self.assertTrue(len(meta.email) > 1)
            self.assertTrue(len(meta.dob) > 1)
            self.assertTrue(meta.age >= 22 and meta.age <= 44)
            self.assertTrue(type(meta.is_married) == bool)

    def test_list_range(self):
        mockingbird = self.mockingbird

        mockingbird.spec(Contact,     {"name": MockRealName(),
                                       "label": MockString(min=4, max=10),
                                       "meta": MockObject(ContactMeta)})

        mockingbird.spec(ContactMeta, {"phone": MockPhoneNumber(),
                                       "email": MockEmail(),
                                       "dob": MockDate(),
                                       "age": MockInt(min=22, max=44),
                                       "is_married": MockBoolean()})

        mockingbird.spec(AddressBook, {"contacts": MockObjectList(Contact, min=5, max=11)})

        address_book = mockingbird.AddressBook()
        total_contacts = len(address_book.contacts)
        
        self.assertIsNotNone(address_book)
        self.assertIsInstance(address_book, AddressBook)
        
        self.assertTrue(total_contacts >= 5 and total_contacts <= 10)

        for contact in address_book.contacts:
            meta = contact.meta

            self.assertIsNotNone(contact)
            self.assertIsInstance(contact, Contact)
            self.assertIsNotNone(contact.name)
            self.assertIsNotNone(contact.label)
            self.assertTrue(len(contact.name) > 1)
            self.assertTrue(len(contact.label) > 1)

            self.assertIsNotNone(meta)
            self.assertIsInstance(meta, ContactMeta)
            self.assertIsNotNone(meta.phone)
            self.assertIsNotNone(meta.email)
            self.assertIsNotNone(meta.dob)
            self.assertIsNotNone(meta.age)
            self.assertIsNotNone(meta.is_married)

            self.assertTrue(len(meta.phone) > 1)
            self.assertTrue(len(meta.email) > 1)
            self.assertTrue(len(meta.dob) > 1)
            self.assertTrue(meta.age >= 22 and meta.age <= 44)
            self.assertTrue(type(meta.is_married) == bool)<commit_msg>cleanup<commit_after>import unittest
import context
from mockingbird import Mockingbird
from mockingbird.generators import MockRealName
from mockingbird.generators import MockString
from mockingbird.generators import MockPhoneNumber
from mockingbird.generators import MockEmail
from mockingbird.generators import MockDate
from mockingbird.generators import MockInt
from mockingbird.generators import MockBoolean
from mockingbird.generators import MockChoice
from mockingbird.generators import MockObject
from mockingbird.generators import MockObjectList

from models import Contact
from models import ContactMeta
from models import AddressBook

class MockingbirdSuite(unittest.TestCase):

    def setUp(self):
        self.mockingbird = Mockingbird()

    def test_spec_key(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact, {})
        data = mockingbird["Contact"]()
        self.assertIsInstance(data, Contact)

    def test_spec_attr(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact, {})
        data = mockingbird.Contact()
        self.assertIsInstance(data, Contact)
            

    def test_realname_string(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact, {"name": MockRealName(),
                                   "label": MockString(min=4, max=10)})

        contact = mockingbird.Contact()

        self.assertIsInstance(contact, Contact)
        self.assertIsNotNone(contact.name)
        self.assertIsNotNone(contact.label)
        self.assertGreater(len(contact.name), 1)
        self.assertGreater(len(contact.label), 1)

    def test_nested(self):
        mockingbird = self.mockingbird
        mockingbird.spec(Contact,     {"name": MockRealName(),
                                       "label": MockString(min=4, max=10),
                                       "meta": MockObject(ContactMeta)})

        mockingbird.spec(ContactMeta, {"phone": MockPhoneNumber(),
                                       "email": MockEmail(),
                                       "dob": MockDate(),
                                       "age": MockInt(min=22, max=44),
                                       "is_married": MockBoolean()})

        contact = mockingbird.Contact()
        meta = contact.meta
        

        self.assertIsNotNone(contact)
        self.assertIsInstance(contact, Contact)
        self.assertIsNotNone(contact.name)
        self.assertIsNotNone(contact.label)
        self.assertTrue(len(contact.name) > 1)
        self.assertTrue(len(contact.label) > 1)

        self.assertIsNotNone(meta)
        self.assertIsInstance(meta, ContactMeta)
        self.assertIsNotNone(meta.phone)
        self.assertIsNotNone(meta.email)
        self.assertIsNotNone(meta.dob)
        self.assertIsNotNone(meta.age)
        self.assertIsNotNone(meta.is_married)

        self.assertTrue(len(meta.phone) > 1)
        self.assertTrue(len(meta.email) > 1)
        self.assertTrue(len(meta.dob) > 1)
        self.assertTrue(meta.age >= 22 and meta.age <= 44)
        self.assertTrue(type(meta.is_married) == bool)

    def test_list_count(self):
        mockingbird = self.mockingbird

        mockingbird.spec(Contact,     {"name": MockRealName(),
                                       "label": MockString(min=4, max=10),
                                       "meta": MockObject(ContactMeta)})

        mockingbird.spec(ContactMeta, {"phone": MockPhoneNumber(),
                                       "email": MockEmail(),
                                       "dob": MockDate(),
                                       "age": MockInt(min=22, max=44),
                                       "is_married": MockBoolean()})

        mockingbird.spec(AddressBook, {"contacts": MockObjectList(Contact, count=5)})

        address_book = mockingbird.AddressBook()
        
        
        self.assertIsNotNone(address_book)
        self.assertIsInstance(address_book, AddressBook)
        self.assertEquals(len(address_book.contacts), 5)

        for contact in address_book.contacts:
            meta = contact.meta

            self.assertIsNotNone(contact)
            self.assertIsInstance(contact, Contact)
            self.assertIsNotNone(contact.name)
            self.assertIsNotNone(contact.label)
            self.assertTrue(len(contact.name) > 1)
            self.assertTrue(len(contact.label) > 1)

            self.assertIsNotNone(meta)
            self.assertIsInstance(meta, ContactMeta)
            self.assertIsNotNone(meta.phone)
            self.assertIsNotNone(meta.email)
            self.assertIsNotNone(meta.dob)
            self.assertIsNotNone(meta.age)
            self.assertIsNotNone(meta.is_married)

            self.assertTrue(len(meta.phone) > 1)
            self.assertTrue(len(meta.email) > 1)
            self.assertTrue(len(meta.dob) > 1)
            self.assertTrue(meta.age >= 22 and meta.age <= 44)
            self.assertTrue(type(meta.is_married) == bool)

    def test_list_range(self):
        mockingbird = self.mockingbird

        mockingbird.spec(Contact,     {"name": MockRealName(),
                                       "label": MockString(min=4, max=10),
                                       "meta": MockObject(ContactMeta)})

        mockingbird.spec(ContactMeta, {"phone": MockPhoneNumber(),
                                       "email": MockEmail(),
                                       "dob": MockDate(),
                                       "age": MockInt(min=22, max=44),
                                       "is_married": MockBoolean()})

        mockingbird.spec(AddressBook, {"contacts": MockObjectList(Contact, min=5, max=11)})

        address_book = mockingbird.AddressBook()
        total_contacts = len(address_book.contacts)
        
        self.assertIsNotNone(address_book)
        self.assertIsInstance(address_book, AddressBook)
        
        self.assertTrue(total_contacts >= 5 and total_contacts <= 10)

        for contact in address_book.contacts:
            meta = contact.meta

            from pprint import pprint
            pprint(contact.__dict__)
            pprint(contact.meta.__dict__)

            self.assertIsNotNone(contact)
            self.assertIsInstance(contact, Contact)
            self.assertIsNotNone(contact.name)
            self.assertIsNotNone(contact.label)
            self.assertTrue(len(contact.name) > 1)
            self.assertTrue(len(contact.label) > 1)

            self.assertIsNotNone(meta)
            self.assertIsInstance(meta, ContactMeta)
            self.assertIsNotNone(meta.phone)
            self.assertIsNotNone(meta.email)
            self.assertIsNotNone(meta.dob)
            self.assertIsNotNone(meta.age)
            self.assertIsNotNone(meta.is_married)

            self.assertTrue(len(meta.phone) > 1)
            self.assertTrue(len(meta.email) > 1)
            self.assertTrue(len(meta.dob) > 1)
            self.assertTrue(meta.age >= 22 and meta.age <= 44)
            self.assertTrue(type(meta.is_married) == bool)
{'fraction_non_alphanumeric': 0.09901625320786997, 'fraction_numerical': 0.008696891930424864, 'mean_word_length': 2.0111611933891393, 'pattern_counts': {'":': 56, '<': 11, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4595957', 'n_tokens_mistral': 3946, 'n_tokens_neox': 3745, 'n_words': 625}