def test_register(mock_identifiers_client, mocked_checksum, logged_in): cli = MinidClient() cli.register('foo.txt') expected = { 'checksums': [{ 'function': 'sha256', 'value': 'mock_checksum' }], 'metadata': { '_profile': 'erc', 'erc.what': 'foo.txt' }, 'location': [], 'namespace': MinidClient.NAMESPACE, 'visible_to': ['public'] } assert expected in mock_identifiers_client.create_identifier.call_args
def test_register_replaces(mock_identifiers_client, logged_in): cli = MinidClient() checksums = [{'function': 'sha256', 'value': 'mock_checksum'}] cli.register(checksums, title='foo.txt', replaces='minid:123456') expected = { 'checksums': [{ 'function': 'sha256', 'value': 'mock_checksum' }], 'metadata': { 'title': 'foo.txt' }, 'location': [], 'namespace': MinidClient.IDENTIFIERS_NAMESPACE, 'visible_to': ['public'], 'replaces': 'hdl:20.500.12582/123456' } assert expected in mock_identifiers_client.create_identifier.call_args
def test_register_unsupported_checksum(mock_identifiers_client, logged_in): cli = MinidClient() checksums = [{ 'function': 'sha256', 'value': 'mock_checksum' }, { 'function': 'NOT_REAL', 'value': 'irrelevant!' }] cli.register(checksums, title='foo.txt') expected = { 'checksums': [{ 'function': 'sha256', 'value': 'mock_checksum' }], 'metadata': { 'title': 'foo.txt' }, 'location': [], 'namespace': MinidClient.IDENTIFIERS_NAMESPACE, 'visible_to': ['public'], } assert expected in mock_identifiers_client.create_identifier.call_args