def test_sign_message_with_default_key(self, gpg_mock, mocker, monkeypatch): gpg_mock._gpg.sign.return_value = self.mock_response(mocker) monkeypatch.setattr(gpg_mock.keys.secret, "current", "CURRENT_KEY") GPG.sign(gpg_mock, self.message, event=False) gpg_mock._gpg.sign.assert_called_once_with(self.message, keyid="CURRENT_KEY")
def test_event(self, gpg_mock, mocker): gpg_mock._gpg.sign.return_value = self.mock_response(mocker) subscription = util.subscribe_event(self.event_class) GPG.sign(gpg_mock, self.message) event = subscription() assert isinstance(event.gpg, GPG) assert event.result.data == self.signed
def test_failure_raises_exception(self, gpg_mock, mocker): gpg_mock._gpg.sign.return_value = self.mock_response( mocker, status="signature failed", stderr="error output") with pytest.raises(exceptions.MessageSignError): GPG.sign(gpg_mock, self.message)
def test_sign_message(self, gpg_mock, keyid, mocker): gpg_mock._gpg.sign.return_value = self.mock_response(mocker) result = GPG.sign(gpg_mock, self.message, key=keyid, event=False) gpg_mock._gpg.sign.assert_called_once_with(self.message, keyid=keyid) assert result == self.signed