|
18 | 18 | AbstractNode, |
19 | 19 | RegistrationApproval, |
20 | 20 | Embargo, |
| 21 | + Sanction, |
21 | 22 | SchemaResponse, |
22 | 23 | DraftRegistration, |
23 | 24 |
|
|
44 | 45 | CheckArchiveStatusRegistrationsView, |
45 | 46 | ForceArchiveRegistrationsView, |
46 | 47 | ApprovalBacklogListView, |
47 | | - ConfirmApproveBacklogView |
| 48 | + ConfirmApproveBacklogView, |
| 49 | + EmbargoReportView, |
48 | 50 | ) |
49 | 51 | from admin_tests.utilities import setup_log_view, setup_view, handle_post_view_request |
50 | 52 | from api_tests.share._utils import mock_update_share |
|
62 | 64 | RegistrationApprovalFactory, |
63 | 65 | RegistrationProviderFactory, |
64 | 66 | DraftRegistrationFactory, |
| 67 | + EmbargoFactory, |
65 | 68 | get_default_metaschema |
66 | 69 | ) |
67 | 70 | from osf.utils.workflows import ApprovalStates, RegistrationModerationStates |
68 | 71 | from osf.utils import permissions |
69 | 72 | from osf.exceptions import NodeStateError |
70 | 73 |
|
71 | 74 |
|
72 | | -from website.settings import REGISTRATION_APPROVAL_TIME |
| 75 | +from website.settings import REGISTRATION_APPROVAL_TIME, EMBARGO_PENDING_TIME |
73 | 76 |
|
74 | 77 |
|
75 | 78 | def patch_messages(request): |
@@ -1116,6 +1119,7 @@ def test_file_is_removed_from_registration_osfstorage(self): |
1116 | 1119 | name=registration_osfstorage.archive_folder_name |
1117 | 1120 | ).children.exists() |
1118 | 1121 | assert not self.registration_registered_from.files.exists() |
| 1122 | +<<<<<<< HEAD |
1119 | 1123 | remove_log = self.registration_registered_from.logs.filter( |
1120 | 1124 | action=NodeLog.FILE_REMOVED, |
1121 | 1125 | foreign_user=NodeLog.SUPPORT_USER_LABEL, |
@@ -1233,3 +1237,65 @@ def test_update_registration_date(self): |
1233 | 1237 | foreign_user=NodeLog.SUPPORT_USER_LABEL, |
1234 | 1238 | ).latest('date') |
1235 | 1239 | assert_support_attributed_log(log, self.admin_user) |
| 1240 | +======= |
| 1241 | + |
| 1242 | + |
| 1243 | +class TestEmbargoReportView(AdminTestCase): |
| 1244 | + |
| 1245 | + def setUp(self): |
| 1246 | + super().setUp() |
| 1247 | + self.request = RequestFactory().get('/nodes/embargo_report/') |
| 1248 | + self.view = setup_log_view(EmbargoReportView(), self.request) |
| 1249 | + |
| 1250 | + def test_pending_past_activation_window_in_report(self): |
| 1251 | + embargo = EmbargoFactory(approve=False) |
| 1252 | + embargo.initiation_date = timezone.now() - EMBARGO_PENDING_TIME - timezone.timedelta(days=1) |
| 1253 | + embargo.save() |
| 1254 | + |
| 1255 | + context = self.view.get_context_data() |
| 1256 | + assert embargo in context['pending_page'] |
| 1257 | + |
| 1258 | + def test_recent_pending_embargo_excluded(self): |
| 1259 | + embargo = EmbargoFactory(approve=False) |
| 1260 | + embargo.initiation_date = timezone.now() |
| 1261 | + embargo.save() |
| 1262 | + |
| 1263 | + context = self.view.get_context_data() |
| 1264 | + assert embargo not in context['pending_page'] |
| 1265 | + |
| 1266 | + def test_active_past_end_date_in_report(self): |
| 1267 | + embargo = EmbargoFactory( |
| 1268 | + approve=True, |
| 1269 | + end_date=timezone.now() - timezone.timedelta(days=1), |
| 1270 | + ) |
| 1271 | + embargo.state = Sanction.APPROVED |
| 1272 | + embargo.save() |
| 1273 | + |
| 1274 | + context = self.view.get_context_data() |
| 1275 | + assert embargo in context['overdue_page'] |
| 1276 | + |
| 1277 | + def test_active_upcoming_in_report(self): |
| 1278 | + embargo = EmbargoFactory( |
| 1279 | + approve=True, |
| 1280 | + end_date=timezone.now() + timezone.timedelta(days=30), |
| 1281 | + ) |
| 1282 | + embargo.state = Sanction.APPROVED |
| 1283 | + embargo.save() |
| 1284 | + |
| 1285 | + context = self.view.get_context_data() |
| 1286 | + assert embargo in context['upcoming_page'] |
| 1287 | + |
| 1288 | + def test_deleted_registration_embargo_excluded(self): |
| 1289 | + embargo = EmbargoFactory( |
| 1290 | + approve=True, |
| 1291 | + end_date=timezone.now() - timezone.timedelta(days=1), |
| 1292 | + ) |
| 1293 | + embargo.state = Sanction.APPROVED |
| 1294 | + embargo.save() |
| 1295 | + registration = embargo.registrations.first() |
| 1296 | + registration.is_deleted = True |
| 1297 | + registration.save() |
| 1298 | + |
| 1299 | + context = self.view.get_context_data() |
| 1300 | + assert embargo not in context['overdue_page'] |
| 1301 | +>>>>>>> upstream/develop |
0 commit comments