예제 #1
0
def test_fs_error_during_checksum(monkeypatch):
    cli = MinidClient()
    hasher_inst = Mock()
    hasher_inst.update.side_effect = Exception
    monkeypatch.setattr(hashlib, 'sha256', Mock(return_value=hasher_inst))
    with pytest.raises(MinidException):
        cli.check(TEST_CHECKSUM_FILE)
예제 #2
0
def test_check_by_checksum(mock_identifiers_client):
    cli = MinidClient()
    cli.check(TEST_CHECKSUM_FILE)
    mock_identifiers_client.get_identifier_by_checksum.assert_called_with(
        TEST_CHECKSUM_VALUE, )
예제 #3
0
def test_checksumming_file_does_not_exist():
    cli = MinidClient()
    with pytest.raises(MinidException):
        cli.check('does_not_exist.txt')
예제 #4
0
def test_check(mock_identifiers_client, mocked_checksum):
    cli = MinidClient()
    cli.check('hdl:20.500.12633/mock-hdl')
    mock_identifiers_client.get_identifier.assert_called_with(
        'hdl:20.500.12633/mock-hdl', )