Best Python code snippet using localstack_python
views.py
Source: views.py
...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,...
test_url.py
Source: test_url.py
...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)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!