# 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/walker.py
# FOLDER = 'application/x-directory'
# class Walker(object):
#     def __init__(self, root, prefix, container_doc, collection):
#     def record_document(self, new_doc, created):
#     def walk(cls, root, prefix, container_doc, collection):
#     def _path(self, file):
#     def handle(self, item, parent):
#     def handle_folder(self, folder, parent):
#     def handle_file(self, file, parent):
# def files_in(doc):
# def _fix_mimetypes():
# 
# Path: snoop/views.py
# def json_response(request, data):
# def _format_size(num):
# def _format_date(date_value):
# def _find_doc(collection_slug, id):
# def document_raw(request, collection_slug, id):
# def document_ocr(request, collection_slug, id, tag):
# def _as_eml(doc):
# def document_as_eml(request, collection_slug, id):
# def _process_document(collection_slug, id, data=None):
# def _get_index_data_format(digest_data):
# def document_json(request, collection_slug, id):
# def feed(request, collection_slug):
#     def dump(digest, digested_at):
# def collection(request, collection_slug):


from pathlib import Path
from tempfile import TemporaryDirectory
from urllib.parse import urljoin
from django.conf import settings
from snoop import models, walker, views
    from snoop.digest import create_children, digest
        from snoop.digest import worker
import pytest
    walker.Walker.walk(
        root=col.path,
        prefix=None,
        container_doc=None,
        collection=col,
    )
    return col

@pytest.fixture
def testdata():
    return _collection(
        slug='apitest',
        path=settings.SNOOP_ROOT + '/eml-2-attachment',
    )

def test_get_data(testdata):
    email = testdata.document_set.get(path='message-without-subject.eml')
    data = views._process_document(testdata.slug, email.id)
    content = data['content']
    assert content['date'] == '2013-10-10T10:04:49-07:00'
    assert content['filetype'] == 'email'
    assert content['filename'] == 'message-without-subject.eml'
    assert content['path'] == 'message-without-subject.eml'
    assert content['from'] == \
        'Negoita Camelia <don.t_mess_with_miky@yahoo.com>'
    assert content['md5'] == '2008f17802012f11fc4b35234a4af672'

def test_attachments(testdata):
    email = testdata.document_set.get(path='message-without-subject.eml')
    new_children = create_children(email, digest(email), True)

# 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/walker.py
# FOLDER = 'application/x-directory'
# class Walker(object):
#     def __init__(self, root, prefix, container_doc, collection):
#     def record_document(self, new_doc, created):
#     def walk(cls, root, prefix, container_doc, collection):
#     def _path(self, file):
#     def handle(self, item, parent):
#     def handle_folder(self, folder, parent):
#     def handle_file(self, file, parent):
# def files_in(doc):
# def _fix_mimetypes():
# 
# Path: snoop/views.py
# def json_response(request, data):
# def _format_size(num):
# def _format_date(date_value):
# def _find_doc(collection_slug, id):
# def document_raw(request, collection_slug, id):
# def document_ocr(request, collection_slug, id, tag):
# def _as_eml(doc):
# def document_as_eml(request, collection_slug, id):
# def _process_document(collection_slug, id, data=None):
# def _get_index_data_format(digest_data):
# def document_json(request, collection_slug, id):
# def feed(request, collection_slug):
#     def dump(digest, digested_at):
# def collection(request, collection_slug):


# Path: testsuite/test_api.py
from pathlib import Path
from tempfile import TemporaryDirectory
from urllib.parse import urljoin
from django.conf import settings
from snoop import models, walker, views
    from snoop.digest import create_children, digest
        from snoop.digest import worker
import pytest

    walker.Walker.walk(
        root=col.path,
        prefix=None,
        container_doc=None,
        collection=col,
    )
    return col

@pytest.fixture
def testdata():
    return _collection(
        slug='apitest',
        path=settings.SNOOP_ROOT + '/eml-2-attachment',
    )

def test_get_data(testdata):
    email = testdata.document_set.get(path='message-without-subject.eml')
    data = views._process_document(testdata.slug, email.id)
    content = data['content']
    assert content['date'] == '2013-10-10T10:04:49-07:00'
    assert content['filetype'] == 'email'
    assert content['filename'] == 'message-without-subject.eml'
    assert content['path'] == 'message-without-subject.eml'
    assert content['from'] == \
        'Negoita Camelia <don.t_mess_with_miky@yahoo.com>'
    assert content['md5'] == '2008f17802012f11fc4b35234a4af672'

def test_attachments(testdata):
    email = testdata.document_set.get(path='message-without-subject.eml')
    new_children = create_children(email, digest(email), True)

    data = views._process_document(testdata.slug, email.id)