Esempio n. 1
0
 def test_parse_agent_no_agents(self):
     """
     It should return None
     """
     assert models.Agent.objects.count() == 0
     agent_id = parse_dataverse.add_external_agents(
         self.job, os.path.join(THIS_DIR, 'fixtures', 'emptysip', ''))
     assert models.Agent.objects.count() == 0
     assert agent_id is None
Esempio n. 2
0
 def test_parse_agent(self):
     """
     It should add a Dataverse agent.
     """
     assert models.Agent.objects.count() == 0
     agent_id = parse_dataverse.add_external_agents(self.job,
                                                    self.unit_path)
     assert models.Agent.objects.count() == 1
     assert agent_id
     agent = models.Agent.objects.all()[0]
     assert agent.identifiertype == 'URI'
     assert agent.identifiervalue == 'http://dataverse.example.com/dvn/'
     assert agent.name == 'Example Dataverse Network'
     assert agent.agenttype == 'organization'
Esempio n. 3
0
 def test_parse_agent_already_exists(self):
     """
     It should not add a duplicate agent.
     """
     models.Agent.objects.create(
         identifiertype='URI',
         identifiervalue='http://dataverse.example.com/dvn/',
         name='Example Dataverse Network',
         agenttype='organization',
     )
     assert models.Agent.objects.count() == 1
     agent_id = parse_dataverse.add_external_agents(self.job,
                                                    self.unit_path)
     assert models.Agent.objects.count() == 1
     assert agent_id
     agent = models.Agent.objects.all()[0]
     assert agent.identifiertype == 'URI'
     assert agent.identifiervalue == 'http://dataverse.example.com/dvn/'
     assert agent.name == 'Example Dataverse Network'
     assert agent.agenttype == 'organization'
Esempio n. 4
0
 def test_parse_derivative(self):
     """
     It should create a Derivation for the tabfile and related.
     """
     assert models.Derivation.objects.count() == 0
     mapping = parse_dataverse.get_db_objects(self.job, self.mets,
                                              self.uuid)
     agent = parse_dataverse.add_external_agents(self.job, self.unit_path)
     parse_dataverse.create_db_entries(self.job, mapping, agent)
     assert models.Event.objects.count() == 2
     assert models.Derivation.objects.count() == 2
     assert models.Derivation.objects.get(
         source_file_id='e2834eed-4178-469a-9a4e-c8f1490bb804',
         derived_file_id='071e6af9-f676-40fa-a5ab-754ca6b653e0',
         event__isnull=False,
     )
     assert models.Derivation.objects.get(
         source_file_id='e2834eed-4178-469a-9a4e-c8f1490bb804',
         derived_file_id='5518a927-bae9-497c-8a16-caa072e6ef7e',
         event__isnull=False,
     )