# 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: 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/pgp.py
# GPG = None
#             GPG = gnupg.GPG(gnupghome=settings.SNOOP_GPG_HOME,
#                             gpgbinary=settings.SNOOP_GPG_BINARY)
# def is_enabled():
# def _get_gpg():
# def extract_pgp_block(content):
# def contains_pgp_block(content):
# def decrypt_pgp_block(content, passphrase=None):
# class DecryptionError(exceptions.BrokenDocument):


import tempfile
import gnupg
import pytest
from django.conf import settings
from snoop import emails, models, pgp
    doc = models.Document(
        path=path,
        content_type='message/rfc822',
        collection=collection,
    )
    doc.save = lambda *a, **k: None
    return doc

def parse_email(path, document_collection):
    return emails.parse_email(create_email_doc(path, document_collection))

def open_email(path, document_collection):
    return emails.open_email(create_email_doc(path, document_collection))

def test_doc_flags(document_collection):
    doc = create_email_doc(PATH_HUSH_MAIL, document_collection)
    emails.parse_email(doc)
    assert doc.flags.get('pgp')

def test_header_data(document_collection):
    data = parse_email(PATH_HUSH_MAIL, document_collection)
    assert data['subject'] == "Fwd: test email"
    assert data['date'] == '2016-08-10T15:00:00'

def test_attachments(document_collection):
    data = parse_email(PATH_HUSH_MAIL, document_collection)
    attach = data['attachments']
    assert len(attach) == 6

    email = open_email(PATH_HUSH_MAIL, document_collection)

# 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: 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/pgp.py
# GPG = None
#             GPG = gnupg.GPG(gnupghome=settings.SNOOP_GPG_HOME,
#                             gpgbinary=settings.SNOOP_GPG_BINARY)
# def is_enabled():
# def _get_gpg():
# def extract_pgp_block(content):
# def contains_pgp_block(content):
# def decrypt_pgp_block(content, passphrase=None):
# class DecryptionError(exceptions.BrokenDocument):


# Path: testsuite/test_pgp_hushmail.py
import tempfile
import gnupg
import pytest
from django.conf import settings
from snoop import emails, models, pgp

    doc = models.Document(
        path=path,
        content_type='message/rfc822',
        collection=collection,
    )
    doc.save = lambda *a, **k: None
    return doc

def parse_email(path, document_collection):
    return emails.parse_email(create_email_doc(path, document_collection))

def open_email(path, document_collection):
    return emails.open_email(create_email_doc(path, document_collection))

def test_doc_flags(document_collection):
    doc = create_email_doc(PATH_HUSH_MAIL, document_collection)
    emails.parse_email(doc)
    assert doc.flags.get('pgp')

def test_header_data(document_collection):
    data = parse_email(PATH_HUSH_MAIL, document_collection)
    assert data['subject'] == "Fwd: test email"
    assert data['date'] == '2016-08-10T15:00:00'

def test_attachments(document_collection):
    data = parse_email(PATH_HUSH_MAIL, document_collection)
    attach = data['attachments']
    assert len(attach) == 6

    email = open_email(PATH_HUSH_MAIL, document_collection)

    assert email.pgp