def test_verify_approver_enforced(self, settings, mocker): settings.PEER_APPROVAL_ENFORCED = True creator = UserFactory() user = UserFactory() req = ApprovalRequestFactory(creator=creator) # Do not raise when creator and approver are different req.verify_approver(user) # Raise when creator and approver are the same with pytest.raises(req.CannotActOnOwnRequest): req.verify_approver(creator)
def test_verify_approver_unenforced(self, settings, mocker): logger = mocker.patch('normandy.recipes.models.logger') settings.PEER_APPROVAL_ENFORCED = False creator = UserFactory() user = UserFactory() req = ApprovalRequestFactory(creator=creator) # Do not raise when creator and approver are different req.verify_approver(user) # Do not raise when creator and approver are the same since enforcement # is disabled. req.verify_approver(creator) logger.warning.assert_called_with(Whatever(), extra={ 'code': WARNING_BYPASSING_PEER_APPROVAL, 'approval_id': req.id, 'approver': creator, })
def test_verify_approver_unenforced(self, settings, mocker): logger = mocker.patch("normandy.recipes.models.logger") settings.PEER_APPROVAL_ENFORCED = False creator = UserFactory() user = UserFactory() req = ApprovalRequestFactory(creator=creator) # Do not raise when creator and approver are different req.verify_approver(user) # Do not raise when creator and approver are the same since enforcement # is disabled. req.verify_approver(creator) logger.warning.assert_called_with( Whatever(), extra={ "code": WARNING_BYPASSING_PEER_APPROVAL, "approval_id": req.id, "approver": creator, }, )