# Path: snoop/models.py
# def cache(model, keyfunc):
#     def decorator(func):
#         def wrapper(*args, **kwargs):
#     def __str__(self):
#     def __str__(self):
#     def absolute_path(self):
#     def _open_file(self):
#     def open(self, filesystem=False):
#     def absolute_path(self):
# class EmailCache(models.Model):
# class Collection(models.Model):
# class Document(models.Model):
#     class Meta:
# class Ocr(models.Model):
#     class Meta:
# class Digest(models.Model):
# class Job(models.Model):
#     class Meta:
# class TikaCache(models.Model):
# class TikaLangCache(models.Model):
# class HtmlTextCache(models.Model):
#                     MB = 1024*1024
# 
# Path: snoop/emails.py
# def decode_header(header):
# def people(headers, header_names):
# def extract_email_data(tree):
#     def __init__(self, file):
#     def parts(self, message, number_bits=[]):
#     def _get_part_content(self, part, number):
#     def open_part(self, number):
#     def parts_tree(self, message):
#         def _header(key, header):
#     def get_tree(self):
#     def get_part_text(self, part):
#         def get_payload(encrypted=False):
#     def get_attachments(self):
#     def _message(self):
#     def get_text(self):
#     def __init__(self, file, path):
#     def _get_part_content(self, part, number):
#     def _message(self):
# def msgcache(func):
#     def wrapper(doc):
# def open_msg(doc):
# def is_email(doc):
# def open_email(doc):
# def get_email_part(doc, part):
# def raw_parse_email(doc):
# def parse_email(doc):
# class CorruptedFile(exceptions.BrokenDocument):
# class PayloadError(exceptions.BrokenDocument):
# class EmailParser(object):
# class MissingEmlxPart(exceptions.BrokenDocument):
# class EmlxParser(EmailParser):


from snoop import models, emails
    data = parse_email(MAIL_PATH_MAPBOX, document_collection)

    assert type(data['to']) is list
    assert len(data['to']) == 1
    assert "penultim_o@yahoo.com" in data['to']

    assert type(data['from']) is str
    assert "newsletter@mapbox.com" in data['from']

def test_normal_attachments(document_collection):
    data = parse_email(MAIL_PATH_CAMPUS, document_collection)
    attachments = data['attachments']

    assert attachments
    assert type(attachments) is dict
    assert len(attachments) == 2

def test_attachment_with_long_filename(document_collection):
    data = parse_email(MAIL_PATH_LONG_FILENAMES, document_collection)
    attachments = data['attachments']

    assert len(attachments) == 3

def test_tree_without_attachments(document_collection):
    data = parse_email(MAIL_PATH_MAPBOX, document_collection)
    tree = data['tree']

    assert set(tree.keys()) == {'headers', 'parts'}
    assert len(tree['parts']) == 2


# Path: snoop/models.py
# def cache(model, keyfunc):
#     def decorator(func):
#         def wrapper(*args, **kwargs):
#     def __str__(self):
#     def __str__(self):
#     def absolute_path(self):
#     def _open_file(self):
#     def open(self, filesystem=False):
#     def absolute_path(self):
# class EmailCache(models.Model):
# class Collection(models.Model):
# class Document(models.Model):
#     class Meta:
# class Ocr(models.Model):
#     class Meta:
# class Digest(models.Model):
# class Job(models.Model):
#     class Meta:
# class TikaCache(models.Model):
# class TikaLangCache(models.Model):
# class HtmlTextCache(models.Model):
#                     MB = 1024*1024
# 
# Path: snoop/emails.py
# def decode_header(header):
# def people(headers, header_names):
# def extract_email_data(tree):
#     def __init__(self, file):
#     def parts(self, message, number_bits=[]):
#     def _get_part_content(self, part, number):
#     def open_part(self, number):
#     def parts_tree(self, message):
#         def _header(key, header):
#     def get_tree(self):
#     def get_part_text(self, part):
#         def get_payload(encrypted=False):
#     def get_attachments(self):
#     def _message(self):
#     def get_text(self):
#     def __init__(self, file, path):
#     def _get_part_content(self, part, number):
#     def _message(self):
# def msgcache(func):
#     def wrapper(doc):
# def open_msg(doc):
# def is_email(doc):
# def open_email(doc):
# def get_email_part(doc, part):
# def raw_parse_email(doc):
# def parse_email(doc):
# class CorruptedFile(exceptions.BrokenDocument):
# class PayloadError(exceptions.BrokenDocument):
# class EmailParser(object):
# class MissingEmlxPart(exceptions.BrokenDocument):
# class EmlxParser(EmailParser):


# Path: testsuite/test_emails.py
from snoop import models, emails

    data = parse_email(MAIL_PATH_MAPBOX, document_collection)

    assert type(data['to']) is list
    assert len(data['to']) == 1
    assert "penultim_o@yahoo.com" in data['to']

    assert type(data['from']) is str
    assert "newsletter@mapbox.com" in data['from']

def test_normal_attachments(document_collection):
    data = parse_email(MAIL_PATH_CAMPUS, document_collection)
    attachments = data['attachments']

    assert attachments
    assert type(attachments) is dict
    assert len(attachments) == 2

def test_attachment_with_long_filename(document_collection):
    data = parse_email(MAIL_PATH_LONG_FILENAMES, document_collection)
    attachments = data['attachments']

    assert len(attachments) == 3

def test_tree_without_attachments(document_collection):
    data = parse_email(MAIL_PATH_MAPBOX, document_collection)
    tree = data['tree']

    assert set(tree.keys()) == {'headers', 'parts'}
    assert len(tree['parts']) == 2


    headers = {'subject', 'to', 'from', 'date', 'content-type'}