def test_update_signature(self, mocker): # Mock the Autographer mock_autograph = mocker.patch('normandy.recipes.models.Autographer') mock_autograph.return_value.sign_data.return_value = [ {'signature': 'fake signature'}, ] recipe = RecipeFactory(signed=False) recipe.update_signature() recipe.save() assert recipe.signature is not None assert recipe.signature.signature == 'fake signature'
def test_update_signature(self, mock_logger, mocked_autograph): recipe = RecipeFactory(enabler=UserFactory(), approver=UserFactory()) recipe.signature = None recipe.update_signature() mock_logger.info.assert_called_with( Whatever.contains(str(recipe.id)), extra={"code": INFO_REQUESTING_RECIPE_SIGNATURES, "recipe_ids": [recipe.id]}, ) mocked_autograph.return_value.sign_data.assert_called_with( [Whatever(lambda s: json.loads(s)["id"] == recipe.id)] ) assert recipe.signature is not None
def test_update_signature(self, mock_logger, mocked_autograph): recipe = RecipeFactory(enabler=UserFactory(), approver=UserFactory()) recipe.signature = None recipe.update_signature() mock_logger.info.assert_called_with( Whatever.contains(str(recipe.id)), extra={"code": INFO_REQUESTING_RECIPE_SIGNATURES, "recipe_ids": [recipe.id]}, ) mocked_autograph.return_value.sign_data.assert_called_with( [Whatever(lambda s: json.loads(s)["id"] == recipe.id)] ) assert recipe.signature is not None
def test_update_signature(self, mocker, mock_logger): # Mock the Autographer mock_autograph = mocker.patch('normandy.recipes.models.Autographer') mock_autograph.return_value.sign_data.return_value = [ { 'signature': 'fake signature' }, ] recipe = RecipeFactory(signed=False) recipe.update_signature() mock_logger.info.assert_called_with( Whatever.contains(str(recipe.id)), extra={ 'code': INFO_REQUESTING_RECIPE_SIGNATURES, 'recipe_ids': [recipe.id] }) recipe.save() assert recipe.signature is not None assert recipe.signature.signature == 'fake signature'