def test_reset_pass_code(app, session): # pylint:disable=unused-argument """Assert that the new passcode in not the same as old passcode.""" entity_model = factory_entity_model(entity_info=TestEntityInfo.entity_passcode) entity = EntityService(entity_model) old_passcode = entity.pass_code entity.reset_passcode(entity.business_identifier, '', TestJwtClaims.user_test) new_passcode = entity.pass_code assert old_passcode != new_passcode
def test_reset_pass_code_confirm_activity_log(app, session): # pylint:disable=unused-argument """Assert that the new passcode in not the same as old passcode.""" entity_model = factory_entity_model(entity_info=TestEntityInfo.entity_passcode) entity = EntityService(entity_model) old_passcode = entity.pass_code with patch.object(activity_log_publisher, 'publish_activity', return_value=None) as mock_send: entity.reset_passcode(entity.business_identifier, '', TestJwtClaims.user_test) new_passcode = entity.pass_code assert old_passcode != new_passcode mock_send.assert_called
def patch(business_identifier): """Update an existing business by it's business number.""" request_json = request.get_json() valid_format, errors = schema_utils.validate(request_json, 'entity') if not valid_format: return {'message': schema_utils.serialize(errors)}, http_status.HTTP_400_BAD_REQUEST passcode_reset = request_json.get('resetPasscode', False) try: if passcode_reset: entity = EntityService.reset_passcode(business_identifier, email_addresses=request_json.get('passcodeResetEmail', None)) else: entity = EntityService.update_entity(business_identifier, request_json) if entity is not None: response, status = entity.as_dict(), http_status.HTTP_200_OK else: response, status = {'message': 'A business for {} was not found.'.format(business_identifier)}, \ http_status.HTTP_404_NOT_FOUND except BusinessException as exception: response, status = {'code': exception.code, 'message': exception.message}, exception.status_code return response, status