Пример #1
0
    def test_020_create_object(self):
        """Create a single test object."""
        client = test_client.TestClient(context.node['baseurl'])

        # scidata_path = test_utilities.get_resource_path(
        #  'd1_testdocs/test_objects/hdl%3A10255%2Fdryad.167%2Fmets.xml')
        # sysmeta_path = test_utilities.get_resource_path(
        #  'd1_testdocs/test_objects/hdl%3A10255%2Fdryad.167%2Fmets.xml.sysmeta')

        context.pid_created = '__invalid_test_object__' + str(uuid.uuid1())

        context.scidata_size = 1024**2 + random.randint(0, 1024)
        context.checksum_algorithm = 'SHA-1'

        context.scidata_file = self.generate_random_file(context.scidata_size)

        context.scidata_file.seek(0)
        context.checksum = test_utilities.calculate_checksum_on_string(
            context.scidata_file, context.checksum_algorithm)

        context.sysmeta_file = self.generate_sysmeta(
            context.pid_created,
            context.scidata_size,
            context.checksum_algorithm,
            context.checksum,
            d1_common.date_time.utc_now(),
        )

        context.scidata_file.seek(0)
        client.create(
            context.TOKEN,
            context.pid_created,
            context.scidata_file,
            context.sysmeta_file,
        )
Пример #2
0
 def test_030_object_exists(self):
     """Verify that created object can be retrieved and that its checksum matches."""
     client = test_client.TestClient(context.node['baseurl'])
     response = client.get(context.TOKEN, context.pid_created)
     # Calculate the checksum.
     checksum = test_utilities.calculate_checksum_on_string(
         response, context.checksum_algorithm)
     assert context.checksum == checksum
Пример #3
0
 def test_030_object_exists(self):
     """Verify that created object can be retrieved and that its checksum matches."""
     client = test_client.TestClient(context.node['baseurl'])
     response = client.get(context.TOKEN, context.pid_created)
     # Calculate the checksum.
     checksum = test_utilities.calculate_checksum_on_string(
         response, context.checksum_algorithm
     )
     assert context.checksum == checksum
Пример #4
0
 def validate_object(self, object_info):
     """Get object and verify retrieved information against its ObjectInfo."""
     # The ObjectInfo records were retrieved during the listObjects tests.
     client = test_client.TestClient(context.node['baseurl'])
     pid = object_info.identifier.value()
     # Verify checksum and checksum algorithm.
     response = client.get(context.TOKEN, pid)
     checksum_from_get = test_utilities.calculate_checksum_on_string(
         response, object_info.checksum.algorithm)
     assert object_info.checksum.value() == checksum_from_get
     # Verify object size.
     response = client.get(context.TOKEN, pid)
     object_size = test_utilities.get_size(response)
     assert object_size == object_info.size
Пример #5
0
 def validate_object(self, object_info):
     """Get object and verify retrieved information against its ObjectInfo."""
     # The ObjectInfo records were retrieved during the listObjects tests.
     client = test_client.TestClient(context.node['baseurl'])
     pid = object_info.identifier.value()
     # Verify checksum and checksum algorithm.
     response = client.get(context.TOKEN, pid)
     checksum_from_get = test_utilities.calculate_checksum_on_string(
         response, object_info.checksum.algorithm
     )
     assert object_info.checksum.value() == checksum_from_get
     # Verify object size.
     response = client.get(context.TOKEN, pid)
     object_size = test_utilities.get_size(response)
     assert object_size == object_info.size
Пример #6
0
    def test_020_create_object(self):
        """Create a single test object."""
        client = test_client.TestClient(context.node['baseurl'])

        # scidata_path = test_utilities.get_resource_path(
        #  'd1_testdocs/test_objects/hdl%3A10255%2Fdryad.167%2Fmets.xml')
        # sysmeta_path = test_utilities.get_resource_path(
        #  'd1_testdocs/test_objects/hdl%3A10255%2Fdryad.167%2Fmets.xml.sysmeta')

        context.pid_created = '__invalid_test_object__' + str(uuid.uuid1())

        context.scidata_size = 1024 ** 2 + random.randint(0, 1024)
        context.checksum_algorithm = 'SHA-1'

        context.scidata_file = self.generate_random_file(context.scidata_size)

        context.scidata_file.seek(0)
        context.checksum = test_utilities.calculate_checksum_on_string(
            context.scidata_file, context.checksum_algorithm
        )

        context.sysmeta_file = self.generate_sysmeta(
            context.pid_created,
            context.scidata_size,
            context.checksum_algorithm,
            context.checksum,
            d1_common.date_time.utc_now(),
        )

        context.scidata_file.seek(0)
        client.create(
            context.TOKEN,
            context.pid_created,
            context.scidata_file,
            context.sysmeta_file,
        )