# Path: premis_event_service/presentation.py
# PREMIS_NAMESPACE = 'info:lc/xmlns/premis-v2'
# PREMIS = '{%s}' % PREMIS_NAMESPACE
# PREMIS_NSMAP = {'premis': PREMIS_NAMESPACE}
# PES_AGENT_ID_TYPE = 'PES:Agent'
# class DuplicateEventError(Exception):
# class NoEventIdentifier(Exception):
# def premisEventXMLToObject(eventXML):
# def premisAgentXMLToObject(agentXML):
# def premisEventXMLgetObject(eventXML):
# def premisAgentXMLgetObject(agentXML):
# def objectToPremisEventXML(eventObject):
# def objectToAgentXML(agentObject):
# def objectToPremisAgentXML(agentObject, webRoot):
# 
# Path: premis_event_service/models.py
# AGENT_TYPE_CHOICES = [
#     ('Personal', 'Personal'),
#     ('Organization', 'Organization'),
#     ('Event', 'Event'),
#     ('Software', 'Software'),
# ]
# class Agent(models.Model):
#     class Meta:
# class LinkObject(models.Model):
# class EventManager(models.Manager):
# class Event(models.Model):
#     class Meta:
# class EventLinkObject(models.Model):
#     class Meta:
#     def __str__(self):
#     def get_absolute_url(self):
#     def __str__(self):
#     def search(self, **kwargs):
#     def searchunfilt(self, max_ordinal=None):
#     def __str__(self):
#     def link_objects_string(self):
#     def is_good(self):
# 
# Path: premis_event_service/settings.py
# EVENT_ID_TYPE_XML = getattr(
#     settings, 'EVENT_ID_TYPE_XML',
#     "http://purl.org/net/untl/vocabularies/identifier-qualifiers/#UUID"
# )
# LINK_AGENT_ID_TYPE_XML = getattr(
#     settings, 'LINK_AGENT_ID_TYPE_XML',
#     "http://purl.org/net/untl/vocabularies/identifier-qualifiers/#URL"
# )
# LINK_AGENT_ID_ROLE_XML = getattr(
#     settings, 'LINK_AGENT_ID_ROLE_XML',
#     "http://id.loc.gov/vocabulary/preservation/eventRelatedAgentRole/exe"
# )
# BAGATOM_BAG_NAMESPACE = getattr(
#     settings, 'BAGATOM_BAG_NAMESPACE', "TODO"
# )
# BAGATOM_QXML_NAMESPACE = getattr(
#     settings, 'BAGATOM_QXML_NAMESPACE', "TODO"
# )
# BAGATOM_NODE_NAMESPACE = getattr(
#     settings, 'BAGATOM_NODE_NAMESPACE', "TODO"
# )
# EVENT_OUTCOME_CHOICES = getattr(
#     settings, 'EVENT_OUTCOME_CHOICES',
#     (
#         ('', 'None'),
#         ('http://purl.org/net/untl/vocabularies/eventOutcomes/#success', 'Success'),
#         ('http://purl.org/net/untl/vocabularies/eventOutcomes/#failure', 'Failure'),
#     )
# )
# EVENT_TYPE_CHOICES = getattr(
#     settings, 'EVENT_TYPE_CHOICES',
#     (
#         ('', 'None'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#fixityCheck', 'Fixity Check'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#replication', 'Replication'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#ingestion', 'Ingestion'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#migration', 'Migration'),
#     )
# )
# ARK_NAAN = getattr(settings, 'ARK_NAAN', 67531)


from datetime import datetime
from unittest.mock import patch
from lxml import etree, objectify
from django.http import HttpResponse, Http404
from django.core.exceptions import ObjectDoesNotExist
from premis_event_service import presentation, models
from premis_event_service import settings
from . import factories
from codalib.xsdatetime import xsDateTime_format, localize_datetime
import pytest
        xml_obj = objectify.fromstring(event_xml.entry_xml)
        del xml_obj.id
        xml_obj.find(
            './/premis:eventIdentifierValue', namespaces=presentation.PREMIS_NSMAP
        ).clear()
        tree = objectify_to_etree(xml_obj)

        factories.EventFactory(event_identifier=event_xml.identifier)

        with pytest.raises(presentation.NoEventIdentifier):
            presentation.premisEventXMLgetObject(tree)

    def test_returns_correct_event_on_uri_id(self, event_xml):
        factories.EventFactory(event_identifier=event_xml.identifier)
        base_id = event_xml.identifier
        event_xml.identifier = 'http://example.com/a/b/c/{}'.format(base_id)
        xml_obj = objectify.fromstring(event_xml.entry_xml)
        tree = objectify_to_etree(xml_obj)
        event_obj = presentation.premisEventXMLgetObject(tree)
        assert event_obj.event_identifier == base_id


@pytest.mark.django_db
class TestPremisAgentXMLGetObjects:

    def test_returns_correct_agent_object(self, agent_xml):
        tree = etree.fromstring(agent_xml.obj_xml)
        factories.AgentFactory(agent_identifier=agent_xml.identifier)
        agent_obj = presentation.premisAgentXMLgetObject(tree)
        assert agent_obj.agent_identifier == agent_xml.identifier

# Path: premis_event_service/presentation.py
# PREMIS_NAMESPACE = 'info:lc/xmlns/premis-v2'
# PREMIS = '{%s}' % PREMIS_NAMESPACE
# PREMIS_NSMAP = {'premis': PREMIS_NAMESPACE}
# PES_AGENT_ID_TYPE = 'PES:Agent'
# class DuplicateEventError(Exception):
# class NoEventIdentifier(Exception):
# def premisEventXMLToObject(eventXML):
# def premisAgentXMLToObject(agentXML):
# def premisEventXMLgetObject(eventXML):
# def premisAgentXMLgetObject(agentXML):
# def objectToPremisEventXML(eventObject):
# def objectToAgentXML(agentObject):
# def objectToPremisAgentXML(agentObject, webRoot):
# 
# Path: premis_event_service/models.py
# AGENT_TYPE_CHOICES = [
#     ('Personal', 'Personal'),
#     ('Organization', 'Organization'),
#     ('Event', 'Event'),
#     ('Software', 'Software'),
# ]
# class Agent(models.Model):
#     class Meta:
# class LinkObject(models.Model):
# class EventManager(models.Manager):
# class Event(models.Model):
#     class Meta:
# class EventLinkObject(models.Model):
#     class Meta:
#     def __str__(self):
#     def get_absolute_url(self):
#     def __str__(self):
#     def search(self, **kwargs):
#     def searchunfilt(self, max_ordinal=None):
#     def __str__(self):
#     def link_objects_string(self):
#     def is_good(self):
# 
# Path: premis_event_service/settings.py
# EVENT_ID_TYPE_XML = getattr(
#     settings, 'EVENT_ID_TYPE_XML',
#     "http://purl.org/net/untl/vocabularies/identifier-qualifiers/#UUID"
# )
# LINK_AGENT_ID_TYPE_XML = getattr(
#     settings, 'LINK_AGENT_ID_TYPE_XML',
#     "http://purl.org/net/untl/vocabularies/identifier-qualifiers/#URL"
# )
# LINK_AGENT_ID_ROLE_XML = getattr(
#     settings, 'LINK_AGENT_ID_ROLE_XML',
#     "http://id.loc.gov/vocabulary/preservation/eventRelatedAgentRole/exe"
# )
# BAGATOM_BAG_NAMESPACE = getattr(
#     settings, 'BAGATOM_BAG_NAMESPACE', "TODO"
# )
# BAGATOM_QXML_NAMESPACE = getattr(
#     settings, 'BAGATOM_QXML_NAMESPACE', "TODO"
# )
# BAGATOM_NODE_NAMESPACE = getattr(
#     settings, 'BAGATOM_NODE_NAMESPACE', "TODO"
# )
# EVENT_OUTCOME_CHOICES = getattr(
#     settings, 'EVENT_OUTCOME_CHOICES',
#     (
#         ('', 'None'),
#         ('http://purl.org/net/untl/vocabularies/eventOutcomes/#success', 'Success'),
#         ('http://purl.org/net/untl/vocabularies/eventOutcomes/#failure', 'Failure'),
#     )
# )
# EVENT_TYPE_CHOICES = getattr(
#     settings, 'EVENT_TYPE_CHOICES',
#     (
#         ('', 'None'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#fixityCheck', 'Fixity Check'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#replication', 'Replication'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#ingestion', 'Ingestion'),
#         ('http://purl.org/net/untl/vocabularies/preservationEvents/#migration', 'Migration'),
#     )
# )
# ARK_NAAN = getattr(settings, 'ARK_NAAN', 67531)


# Path: tests/test_presentation.py
from datetime import datetime
from unittest.mock import patch
from lxml import etree, objectify
from django.http import HttpResponse, Http404
from django.core.exceptions import ObjectDoesNotExist
from premis_event_service import presentation, models
from premis_event_service import settings
from . import factories
from codalib.xsdatetime import xsDateTime_format, localize_datetime
import pytest

        xml_obj = objectify.fromstring(event_xml.entry_xml)
        del xml_obj.id
        xml_obj.find(
            './/premis:eventIdentifierValue', namespaces=presentation.PREMIS_NSMAP
        ).clear()
        tree = objectify_to_etree(xml_obj)

        factories.EventFactory(event_identifier=event_xml.identifier)

        with pytest.raises(presentation.NoEventIdentifier):
            presentation.premisEventXMLgetObject(tree)

    def test_returns_correct_event_on_uri_id(self, event_xml):
        factories.EventFactory(event_identifier=event_xml.identifier)
        base_id = event_xml.identifier
        event_xml.identifier = 'http://example.com/a/b/c/{}'.format(base_id)
        xml_obj = objectify.fromstring(event_xml.entry_xml)
        tree = objectify_to_etree(xml_obj)
        event_obj = presentation.premisEventXMLgetObject(tree)
        assert event_obj.event_identifier == base_id


@pytest.mark.django_db
class TestPremisAgentXMLGetObjects:

    def test_returns_correct_agent_object(self, agent_xml):
        tree = etree.fromstring(agent_xml.obj_xml)
        factories.AgentFactory(agent_identifier=agent_xml.identifier)
        agent_obj = presentation.premisAgentXMLgetObject(tree)
        assert agent_obj.agent_identifier == agent_xml.identifier

        assert isinstance(agent_obj, models.Agent)