How to use add_query_params_to_url method in localstack

Best Python code snippet using localstack_python

views.py

Source:views.py Github

copy

Full Screen

...35 # Failing that, LOGIN_REDIRECT_URL from settings.py.36 redirect_uri = post_or_get(37 request, 'next', fallback=post_or_get(38 request, 'redirect_url', fallback=settings.LOGIN_REDIRECT_URL))39 redirect_absolute_uri = add_query_params_to_url(40 request.build_absolute_uri(redirect_uri),41 {'auth_user': request.user.get_username()})42 if request.method == 'POST':43 form = LoginForm(request.POST)44 if form.is_valid():45 username = form.cleaned_data['username'].lower()46 password = form.cleaned_data['password']47 user = datahub_authenticate(username, password)48 if user is not None and user.is_active:49 django_login(request, user)50 # Append auth_user to redirect_uri so apps like Kibitz can51 # pull the username out of the redirect. This should be52 # removed when Thrift is removed from DataHub.53 redirect_uri = add_query_params_to_url(54 redirect_uri, {'auth_user': request.user.get_username()})55 return HttpResponseRedirect(redirect_uri)56 else:57 form.add_error(None, "Username and password do not match.")58 else:59 # Form isn't valid. Fall through to return it to the user with60 # errors.61 pass62 else:63 form = LoginForm()64 providers = provider_details()65 context = RequestContext(request, {66 'request': request,67 'user': request.user,68 'form': form,69 'providers': providers,70 'next': redirect_uri,71 'absolute_next': redirect_absolute_uri})72 return render_to_response('login.html', context_instance=context)73def register(request):74 """75 DataHub account registration form.76 GET returns an HttpResponse containing the account registration form.77 POST creates a name/email/password account and logs the new user in.78 Other links from the page lead to Python Social Auth options (Google,79 Facebook, Twitter, etc).80 """81 # Redirect succesful logins to `next` if set.82 # Failing that `redirect_url`.83 # Failing that, LOGIN_REDIRECT_URL from settings.py.84 redirect_uri = post_or_get(85 request, 'next', fallback=post_or_get(86 request, 'redirect_url', fallback=settings.LOGIN_REDIRECT_URL))87 redirect_absolute_uri = add_query_params_to_url(88 request.build_absolute_uri(redirect_uri),89 {'auth_user': request.user.get_username()})90 if request.method == 'POST':91 form = RegistrationForm(request.POST)92 if form.is_valid():93 username = form.cleaned_data['username'].lower()94 email = form.cleaned_data['email'].lower()95 password = form.cleaned_data['password']96 User.objects.create_user(username, email, password)97 # A signal handler in signals.py listens for the pre_save signal98 # and throws an IntegrityError if the user's email address is not99 # unique. Username uniqueness is handled by the model.100 #101 # In the future, another pre_save signal handler will check if a102 # DataHub database exists for the user and create one if it103 # doesn't exist. If the database cannot be created, that handler104 # will throw an exception.105 user = datahub_authenticate(username, password)106 if user is not None and user.is_active:107 django_login(request, user)108 # Append auth_user to redirect_uri so apps like Kibitz can109 # pull the username out of the redirect. This should be110 # removed when Thrift is removed from DataHub.111 redirect_uri = add_query_params_to_url(112 redirect_uri, {'auth_user': request.user.get_username()})113 return HttpResponseRedirect(redirect_uri)114 else:115 # Form isn't valid. Fall through and return it to the user with116 # errors.117 pass118 else:119 form = RegistrationForm()120 providers = provider_details()121 context = RequestContext(request, {122 'request': request,123 'user': request.user,124 'form': form,125 'providers': providers,...

Full Screen

Full Screen

test_url.py

Source:test_url.py Github

copy

Full Screen

...24def test_build_url_from_path_and_param(path, params, expected):25 assert utils.url.build_url_from_path_and_params(path, params) == expected26def test_add_params_to_url_start_with_plain_url():27 params = {"b": "test"}28 assert utils.url.add_query_params_to_url("http://example.com", params) == "http://example.com?b=test"29def test_add_params_to_url_existing_params():30 params = {"a": 5}31 res = utils.url.add_query_params_to_url("http://example.com?b=test", params)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful