original_docstring: 
          @param return_url_param - encoded url to be given as param - if None
                         then assume redirect is specified in pylons config
          @param expected_redirect - url we expect to redirect to (but <NAME>
                         not yet substituted)
          @param pkg_name_to_edit - '' means create a new dataset
          
docstring: @param return_url_param - encoded url to be given as param - if None
  then assume redirect is specified in pylons config
  @param expected_redirect - url we expect to redirect to (but 
  not yet substituted)
  @param pkg_name_to_edit - '' means create a new dataset
docstring_tokens: @param return_url_param - encoded url to be given as param - if None then assume redirect is specified in pylons config @param expected_redirect - url we expect to redirect to ( but not yet substituted ) @param pkg_name_to_edit - ' ' means create a new dataset
code: def _check_redirect(
          self,
          app,
          return_url_param,
          expected_redirect,
          pkg_name_to_edit="",
          extra_environ=None,
      ):
          """
          @param return_url_param - encoded url to be given as param - if None
                         then assume redirect is specified in pylons config
          @param expected_redirect - url we expect to redirect to (but <NAME>
                         not yet substituted)
          @param pkg_name_to_edit - '' means create a new dataset
          """
          try:
              new_name = u"new-name"
              offset_params = {}
              if pkg_name_to_edit:
                  pkg_name = pkg_name_to_edit
                  pkg = model.Package.by_name(pkg_name)
                  assert pkg
                  pkg_id = pkg.id
                  named_route = "dataset.edit"
                  offset_params["id"] = pkg_name_to_edit
              else:
                  named_route = "dataset.new"
                  pkg_id = ""
              if return_url_param:
                  offset_params["return_to"] = return_url_param
              offset = url_for(named_route, **offset_params)
              res = app.post(offset, extra_environ=extra_environ, data={
                  "name": new_name,
                  "save": ""
              }, follow_redirects=False)
  
              assert not "Error" in res, res
              redirected_to = res.headers['location']
  
              expected_redirect_url = expected_redirect.replace(
                  "<NAME>", new_name
              )
              assert redirected_to == expected_redirect_url, (
                  "Redirected to %s but should have been %s"
                  % (redirected_to, expected_redirect_url)
              )
          finally:
              # revert name change or pkg creation
              pkg = model.Package.by_name(new_name)
              if pkg:
                  if pkg_name_to_edit:
                      pkg.name = pkg_name_to_edit
                  else:
                      pkg.purge()
                  model.repo.commit_and_remove()
code_tokens: def _check_redirect ( self , app , return_url_param , expected_redirect , pkg_name_to_edit = "" , extra_environ = None , ) : try : new_name = u"new-name" offset_params = { } if pkg_name_to_edit : pkg_name = pkg_name_to_edit pkg = model . Package . by_name ( pkg_name ) assert pkg pkg_id = pkg . id named_route = "dataset.edit" offset_params [ "id" ] = pkg_name_to_edit else : named_route = "dataset.new" pkg_id = "" if return_url_param : offset_params [ "return_to" ] = return_url_param offset = url_for ( named_route , ** offset_params ) res = app . post ( offset , extra_environ = extra_environ , data = { "name" : new_name , "save" : "" } , follow_redirects = False ) assert not "Error" in res , res redirected_to = res . headers [ 'location' ] expected_redirect_url = expected_redirect . replace ( "<NAME>" , new_name ) assert redirected_to == expected_redirect_url , ( "Redirected to %s but should have been %s" % ( redirected_to , expected_redirect_url ) ) finally : pkg = model . Package . by_name ( new_name ) if pkg : if pkg_name_to_edit : pkg . name = pkg_name_to_edit else : pkg . purge ( ) model . repo . commit_and_remove ( )
short_docstring: @param return_url_param - encoded url to be given as param - if None
  then assume redirect is specified in pylons config
  @param expected_redirect - url we expect to redirect to (but <NAME>
  not yet substituted)
  @param pkg_name_to_edit - '' means create a new dataset
short_docstring_tokens: @param return_url_param - encoded url to be given as param - if None then assume redirect is specified in pylons config @param expected_redirect - url we expect to redirect to ( but <NAME > not yet substituted ) @param pkg_name_to_edit - ' ' means create a new dataset
comment: """
          @param return_url_param - encoded url to be given as param - if None
                         then assume redirect is specified in pylons config
          @param expected_redirect - url we expect to redirect to (but <NAME>
                         not yet substituted)
          @param pkg_name_to_edit - '' means create a new dataset
          """$SEP$# revert name change or pkg creation