# Path: pyas2/models.py
# DEFAULT_ENTRY = ('', "---------")
#     CONTENT_TYPE_CHOICES = (
#         ('application/EDI-X12', 'application/EDI-X12'),
#         ('application/EDIFACT', 'application/EDIFACT'),
#         ('application/edi-consent', 'application/edi-consent'),
#         ('application/XML', 'application/XML'),
#         ('text/CSV', 'text/CSV'),
#     )
#     ENCRYPT_ALG_CHOICES = (
#         ('des_ede3_cbc', '3DES'),
#         ('des_cbc', 'DES'),
#         ('aes_128_cbc', 'AES-128'),
#         ('aes_192_cbc', 'AES-192'),
#         ('aes_256_cbc', 'AES-256'),
#         ('rc2_40_cbc', 'RC2-40'),
#     )
#     SIGN_ALG_CHOICES = (
#         ('sha1', 'SHA-1'),
#     )
#     MDN_TYPE_CHOICES = (
#         ('SYNC', 'Synchronous'),
#         ('ASYNC', 'Asynchronous'),
#     )
#     DIRECTION_CHOICES = (
#         ('IN', _('Inbound')),
#         ('OUT', _('Outbound')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#         ('P', _('Pending')),
#         ('R', _('Retry')),
#         ('IP', _('In Process')),
#     )
#     MODE_CHOICES = (
#         ('SYNC', _('Synchronous')),
#         ('ASYNC', _('Asynchronous')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Sent')),
#         ('R', _('Received')),
#         ('P', _('Pending')),
#     )
# def get_certificate_path(instance, filename):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# def getorganizations():
# def getpartners():
# def check_odirs(sender, instance, created, **kwargs):
# def check_pdirs(sender, instance, created, **kwargs):
# def update_dirs():
# class PrivateCertificate(models.Model):
# class PublicCertificate(models.Model):
# class Organization(models.Model):
# class Partner(models.Model):
# class Message(models.Model):
# class Payload(models.Model):
# class Log(models.Model):
# class MDN(models.Model):
# 
# Path: pyas2/as2lib.py
# def decompress_message(message, payload):
# def save_message(message, payload, raw_payload):
# def build_mdn(message, status, **kwargs):
# def build_message(message):
# def send_message(message, payload):
# def save_mdn(message, mdn_content):
# def run_post_send(message):
# def run_post_receive(message, full_filename):


from django.test import TestCase, Client
from pyas2 import models
from pyas2 import as2lib
from email import utils as emailutils
from email.parser import HeaderParser
from email import message_from_string
from itertools import izip
import os
        with open(out_message.mdn.file, 'rb') as mdn_file:
            mdn_content = mdn_file.read()

        # Switch the out and in messages, this is to prevent duplicate message from being picked
        out_message.delete()
        in_message.pk = message_id
        in_message.payload = None
        in_message.save()

        # Send the async mdn and check for its status
        content_type = http_headers.pop('HTTP_CONTENT_TYPE')
        response = self.client.post('/pyas2/as2receive',
                                    data=mdn_content,
                                    content_type=content_type,
                                    **http_headers)
        self.assertEqual(response.status_code, 200)

        in_message = models.Message.objects.get(message_id=message_id)
        # AS2SendReceiveTest.printLogs(in_message)
        self.assertEqual(in_message.status, 'S')

    def buildSendMessage(self, message_id, partner):
        """ Function builds the message and posts the request. """

        message = models.Message.objects.create(message_id='%s_IN' % message_id,
                                                partner=partner,
                                                organization=self.organization,
                                                direction='OUT',
                                                status='IP',
                                                payload=self.payload)

# Path: pyas2/models.py
# DEFAULT_ENTRY = ('', "---------")
#     CONTENT_TYPE_CHOICES = (
#         ('application/EDI-X12', 'application/EDI-X12'),
#         ('application/EDIFACT', 'application/EDIFACT'),
#         ('application/edi-consent', 'application/edi-consent'),
#         ('application/XML', 'application/XML'),
#         ('text/CSV', 'text/CSV'),
#     )
#     ENCRYPT_ALG_CHOICES = (
#         ('des_ede3_cbc', '3DES'),
#         ('des_cbc', 'DES'),
#         ('aes_128_cbc', 'AES-128'),
#         ('aes_192_cbc', 'AES-192'),
#         ('aes_256_cbc', 'AES-256'),
#         ('rc2_40_cbc', 'RC2-40'),
#     )
#     SIGN_ALG_CHOICES = (
#         ('sha1', 'SHA-1'),
#     )
#     MDN_TYPE_CHOICES = (
#         ('SYNC', 'Synchronous'),
#         ('ASYNC', 'Asynchronous'),
#     )
#     DIRECTION_CHOICES = (
#         ('IN', _('Inbound')),
#         ('OUT', _('Outbound')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#         ('P', _('Pending')),
#         ('R', _('Retry')),
#         ('IP', _('In Process')),
#     )
#     MODE_CHOICES = (
#         ('SYNC', _('Synchronous')),
#         ('ASYNC', _('Asynchronous')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Sent')),
#         ('R', _('Received')),
#         ('P', _('Pending')),
#     )
# def get_certificate_path(instance, filename):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# def getorganizations():
# def getpartners():
# def check_odirs(sender, instance, created, **kwargs):
# def check_pdirs(sender, instance, created, **kwargs):
# def update_dirs():
# class PrivateCertificate(models.Model):
# class PublicCertificate(models.Model):
# class Organization(models.Model):
# class Partner(models.Model):
# class Message(models.Model):
# class Payload(models.Model):
# class Log(models.Model):
# class MDN(models.Model):
# 
# Path: pyas2/as2lib.py
# def decompress_message(message, payload):
# def save_message(message, payload, raw_payload):
# def build_mdn(message, status, **kwargs):
# def build_message(message):
# def send_message(message, payload):
# def save_mdn(message, mdn_content):
# def run_post_send(message):
# def run_post_receive(message, full_filename):


# Path: pyas2/tests/tests.py
from django.test import TestCase, Client
from pyas2 import models
from pyas2 import as2lib
from email import utils as emailutils
from email.parser import HeaderParser
from email import message_from_string
from itertools import izip
import os

        with open(out_message.mdn.file, 'rb') as mdn_file:
            mdn_content = mdn_file.read()

        # Switch the out and in messages, this is to prevent duplicate message from being picked
        out_message.delete()
        in_message.pk = message_id
        in_message.payload = None
        in_message.save()

        # Send the async mdn and check for its status
        content_type = http_headers.pop('HTTP_CONTENT_TYPE')
        response = self.client.post('/pyas2/as2receive',
                                    data=mdn_content,
                                    content_type=content_type,
                                    **http_headers)
        self.assertEqual(response.status_code, 200)

        in_message = models.Message.objects.get(message_id=message_id)
        # AS2SendReceiveTest.printLogs(in_message)
        self.assertEqual(in_message.status, 'S')

    def buildSendMessage(self, message_id, partner):
        """ Function builds the message and posts the request. """

        message = models.Message.objects.create(message_id='%s_IN' % message_id,
                                                partner=partner,
                                                organization=self.organization,
                                                direction='OUT',
                                                status='IP',
                                                payload=self.payload)

        processed_payload = as2lib.build_message(message)