# 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
                           "long file names..eml"
MAIL_PATH_NO_SUBJECT = "eml-2-attachment/message-without-subject.eml"
MAIL_PATH_OCTET_STREAM_CONTENT_TYPE = "eml-2-attachment/attachments-have-" \
                                      "octet-stream-content-type.eml"

MAIL_PATH_DOUBLE_DECODE_ATTACHMENT_FILENAME = "eml-8-double-encoded/double-" \
                                              "encoding.eml"

MAIL_PATH_BYTE_ORDER_MARK = "eml-bom/with-bom.eml"

def parse_email(path, collection):
    doc = models.Document(
        path=path,
        content_type='message/rfc822',
        collection=collection
    )
    return emails.parse_email(doc)

def test_subject(document_collection):
    data = parse_email(MAIL_PATH_MAPBOX, document_collection)
    assert data['subject'] == "Introducing Mapbox Android Services"

def test_no_subject_or_text(document_collection):
    data = parse_email(MAIL_PATH_NO_SUBJECT, document_collection)

    assert 'subject' in data
    assert len(data['subject']) == 0
    assert type(data['subject']) is str

    text = data['text']

# 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

                           "long file names..eml"
MAIL_PATH_NO_SUBJECT = "eml-2-attachment/message-without-subject.eml"
MAIL_PATH_OCTET_STREAM_CONTENT_TYPE = "eml-2-attachment/attachments-have-" \
                                      "octet-stream-content-type.eml"

MAIL_PATH_DOUBLE_DECODE_ATTACHMENT_FILENAME = "eml-8-double-encoded/double-" \
                                              "encoding.eml"

MAIL_PATH_BYTE_ORDER_MARK = "eml-bom/with-bom.eml"

def parse_email(path, collection):
    doc = models.Document(
        path=path,
        content_type='message/rfc822',
        collection=collection
    )
    return emails.parse_email(doc)

def test_subject(document_collection):
    data = parse_email(MAIL_PATH_MAPBOX, document_collection)
    assert data['subject'] == "Introducing Mapbox Android Services"

def test_no_subject_or_text(document_collection):
    data = parse_email(MAIL_PATH_NO_SUBJECT, document_collection)

    assert 'subject' in data
    assert len(data['subject']) == 0
    assert type(data['subject']) is str

    text = data['text']

    assert type(text) is str