Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
helrond committed Nov 11, 2024
1 parent 8288b6e commit 5580da1
Showing 1 changed file with 93 additions and 6 deletions.
99 changes: 93 additions & 6 deletions process_request/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from django.urls import reverse
from rest_framework.test import APIRequestFactory

from .helpers import (get_container_indicators, get_dates, get_file_versions,
get_formatted_resource_id, get_instance_data,
get_locations, get_parent_title, get_preferred_format,
get_resource_creators, get_restricted_in_container,
get_rights_info, get_rights_status, get_rights_text,
get_size, indicator_to_integer, prepare_values)
from .helpers import (get_active_rights_acts, get_container_indicators,
get_dates, get_file_versions, get_formatted_resource_id,
get_instance_data, get_locations, get_parent_title,
get_preferred_format, get_resource_creators,
get_restricted_in_container, get_rights_info,
get_rights_status, get_rights_text, get_size,
indicator_to_integer, prepare_values)
from .models import User
from .routines import AeonRequester, Mailer, Processor
from .test_helpers import json_from_fixture, random_list, random_string
Expand Down Expand Up @@ -55,6 +56,92 @@ def setUp(self):
password=settings.ARCHIVESSPACE["password"],
repository=settings.ARCHIVESSPACE["repo_id"]).client

def test_get_active_rights_acts(self):
"""Assert """
acts = [
{
'start_date': '1886-01-01',
'end_date': '1967-12-31',
'created_by': 'aquarius',
'last_modified_by': 'aquarius',
'create_time': '2022-06-08T20:55:05Z',
'system_mtime': '2022-06-08T20:55:05Z',
'user_mtime': '2022-06-08T20:55:05Z',
'act_type': 'publish',
'restriction':
'disallow',
'jsonmodel_type':
'rights_statement_act',
'notes': []
},
{
'start_date': '1886-01-01',
'end_date': '2020-12-31',
'created_by': 'aquarius',
'last_modified_by': 'aquarius',
'create_time': '2022-06-08T20:55:05Z',
'system_mtime': '2022-06-08T20:55:05Z',
'user_mtime': '2022-06-08T20:55:05Z',
'act_type': 'publish',
'restriction':
'disallow',
'jsonmodel_type':
'rights_statement_act',
'notes': []
}]
output = get_active_rights_acts(acts)
self.assertEqual(output, [])

acts = [
{
'start_date': '1886-01-01',
'end_date': '1967-12-31',
'created_by': 'aquarius',
'last_modified_by': 'aquarius',
'create_time': '2022-06-08T20:55:05Z',
'system_mtime': '2022-06-08T20:55:05Z',
'user_mtime': '2022-06-08T20:55:05Z',
'act_type': 'publish',
'restriction':
'disallow',
'jsonmodel_type':
'rights_statement_act',
'notes': []
},
{
'start_date': '1886-01-01',
'end_date': '2070-12-31',
'created_by': 'aquarius',
'last_modified_by': 'aquarius',
'create_time': '2022-06-08T20:55:05Z',
'system_mtime': '2022-06-08T20:55:05Z',
'user_mtime': '2022-06-08T20:55:05Z',
'act_type': 'publish',
'restriction':
'disallow',
'jsonmodel_type':
'rights_statement_act',
'notes': []
}]
expected = [
{
'start_date': '1886-01-01',
'end_date': '2070-12-31',
'created_by': 'aquarius',
'last_modified_by': 'aquarius',
'create_time': '2022-06-08T20:55:05Z',
'system_mtime': '2022-06-08T20:55:05Z',
'user_mtime': '2022-06-08T20:55:05Z',
'act_type': 'publish',
'restriction':
'disallow',
'jsonmodel_type':
'rights_statement_act',
'notes': []
}]
output = get_active_rights_acts(acts)
self.assertEqual(output, expected)

@patch("asnake.client.web_client.ASnakeClient")
def test_get_resource_creators(self, mock_client):
mock_client.get.return_value.json.return_value = {"results": [{"title": "Philanthropy Foundation"}]}
Expand Down

0 comments on commit 5580da1

Please sign in to comment.