def test_080_date_range_3(self):
     """fromDate and toDate parameters are accepted together and limit the number of
     returned objects."""
     # Find two unique datetimes.
     dates = []
     for object_list in context.slices:
         for object_info in object_list.objectInfo:
             dates.append(object_info.dateSysMetadataModified)
     dates.sort()
     # A range query between the lowest and highest datetime in the range must
     # include at last the number of objects that were included in the three
     # slices.
     client = test_client.TestClient(context.node["baseurl"])
     object_list = client.listObjects(
         context.TOKEN,
         fromDate=dates[0],
         toDate=dates[-1],
         count=d1_common.const.DEFAULT_SLICE_SIZE,
     )
     assert object_list.count >= len(dates)
 def xevent_log_contains_create_events(self):
     """Event log contains create events for all objects that are
 currently known.
 Timestamp slicing includes the correct object.
 """
     dates = []
     for object_list in context.slices:
         for object_info in object_list.objectInfo:
             dates.append(object_info.dateSysMetadataModified)
     client = test_client.TestClient(context.node['baseurl'])
     logRecords = client.getLogRecords('<dummy token>',
                                       datetime.datetime(1800, 1, 1))
     assert len(logRecords.logEntry) == EVENTS_TOTAL
     found = False
     for o in logRecords.logEntry:
         if o.identifier.value(
         ) == 'hdl:10255/dryad.654/mets.xml' and o.event == 'create':
             found = True
             break
     assert found
 def test_075_date_range_2(self):
     """fromDate and toDate correctly split the number of returned
 objects.
 """
     # Find middle timestamp.
     dates = []
     for object_list in context.slices:
         for object_info in object_list.objectInfo:
             dates.append(object_info.dateSysMetadataModified)
     dates.sort()
     client = test_client.TestClient(context.node['baseurl'])
     middle_date = dates[7]
     # Get object count for objects with timestamps lower than middle_date.
     low = client.listObjects(context.TOKEN, toDate=middle_date).total
     # Get object count for objects with timestamps higher or equal to
     # middle_date.
     high = client.listObjects(context.TOKEN, fromDate=middle_date).total
     # Check that the separate totals match the total number of objects in the
     # collection.
     self.assertEqual(low + high, context.object_total)
Beispiel #4
0
 def test_020_get_sysmeta_by_valid_pid(self):
     """Successful retrieval of valid SysMeta objects."""
     client = test_client.TestClient(context.node['baseurl'])
     for object_list in context.slices:
         for object_info in object_list.objectInfo:
             pid = object_info.identifier.value()
             sys_meta = client.getSystemMetadata(context.TOKEN, pid)
             # Verify that identifier in SysMeta matches the one that was retrieved.
             assert object_info.identifier.value() == sys_meta.identifier.value()
             # Verify that object format matches listObjects.
             assert object_info.objectFormat == sys_meta.objectFormat
             # Verify that date matches listObjects.
             assert (
                 object_info.dateSysMetadataModified
                 == sys_meta.dateSysMetadataModified
             )
             # Verify that size matches listObjects.
             assert object_info.size == sys_meta.size
             # Verify that checksum and checksum algorithm matches listObjects.
             assert object_info.checksum.value() == sys_meta.checksum.value()
             assert object_info.checksum.algorithm == sys_meta.checksum.algorithm
Beispiel #5
0
 def test_010_get_object_by_invalid_pid(self):
     """404 NotFound when attempting to get non-existing object."""
     client = test_client.TestClient(context.node['baseurl'])
     with pytest.raises(d1_common.types.exceptions.NotFound):
         client.get(context.TOKEN, '_invalid_pid_')
 def test_060_invalid_request_negative_count(self):
   """Negative 'count' parameter returns InvalidRequest.
   """
   client = test_client.TestClient(context.node['baseurl'])
   with pytest.raises(d1_common.types.exceptions.InvalidRequest):
     client.listObjects(context.TOKEN, count=-1)
Beispiel #7
0
 def test_080_total_number_of_objects_increased_by_one(self):
     """Total number of objects reported by listObjects increased by one."""
     client = test_client.TestClient(context.node['baseurl'])
     object_list = client.listObjects(context.TOKEN, start=0, count=0)
     assert object_list.total == context.object_total + 1
Beispiel #8
0
 def test_040_log_records_total_increased_by_one(self):
     """Total number of log records increased by one."""
     client = test_client.TestClient(context.node['baseurl'])
     log_records = client.getLogRecords(context.TOKEN,
                                        datetime.datetime(1800, 1, 1), 0, 0)
     assert context.log_records_total == log_records.total + 1
 def test_020_get_total_events(self):
     """Get total number of events."""
     client = test_client.TestClient(context.node["baseurl"])
     log_records = client.getLogRecords(context.TOKEN, datetime.datetime(1800, 1, 1))
     context.log_records_total = log_records.total
 def test_010_ping(self):
     """Ping() does not raise."""
     client = test_client.TestClient(context.node["baseurl"])
     # The ping() call passes if it doesn't raise.
     client.ping()
 def test_010_get_checksum_by_invalid_pid(self):
     """404 NotFound when attempting to get checksum for non-existing object.
 """
     client = test_client.TestClient(context.node['baseurl'])
     self.assertRaises(d1_common.types.exceptions.NotFound, client.get,
                       context.TOKEN, '_invalid_pid_')
 def test_050_invalid_request_invalid_count(self):
     """count parameter higher than DEFAULT_SLICE_SIZE returns InvalidRequest."""
     client = test_client.TestClient(context.node['baseurl'])
     with pytest.raises(d1_common.types.exceptions.InvalidRequest):
         client.listObjects(context.TOKEN,
                            count=d1_common.const.DEFAULT_SLICE_SIZE + 1)
Beispiel #13
0
 def test_010_get_sysmeta_by_invalid_pid(self):
     """404 NotFound when attempting to get non-existing SysMeta."""
     client = test_client.TestClient(context.node["baseurl"])
     with pytest.raises(d1_common.types.exceptions.NotFound):
         client.getSystemMetadata(context.TOKEN, "_invalid_pid_")