How to use get_url method in pyresttest

Best Python code snippet using pyresttest_python

tests_user.py

Source:tests_user.py Github

copy

Full Screen

1import pytest2from Logic import user_logic3from urllib.parse import urljoin4class Test_user:5 def test_sign_up_same_id(self, get_url, get_tests_data):6 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])7 r2 = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name="lironshani")8 if "error" not in r2.text:9 r = user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])10 print(r.text)11 assert "error" in r.text12 else:13 assert False14 @pytest.mark.parametrize("sign_up_test_case", ["sign_up_no_password", "sign_up_no_user_name", "sign_up_user_name_integer", "sign_up_password_integer", "sign_up_empty_name", "sign_up_empty_password"])15 def test_sign_up(self, get_url, get_tests_data, sign_up_test_case):16 r = user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data[sign_up_test_case])17 assert not r.ok18 def test_add_friend_success(self, get_url, get_tests_data):19 user_logic.add_friend(url=urljoin(get_url, "/users/add_friend"), json=get_tests_data["add_friend_success"])20 r = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["add_friend_success"]["user_name"])21 assert r.ok22 def test_add_friend_no_password(self, get_url, get_tests_data):23 r = user_logic.add_friend(url=urljoin(get_url, "/users/add_friend"), json=get_tests_data["add_friend_no_password"])24 assert not r.ok25 def test_add_friend_wrong_password(self, get_url, get_tests_data):26 r = user_logic.add_friend(url=urljoin(get_url, "/users/add_friend"), json=get_tests_data["add_friend_wrong_password"])27 print(r.text)28 assert "error" in r.text29 @pytest.mark.parametrize("add_friend_test_case", ["add_friend_same_user", "add_friend_not_exist"])30 def test_add_friend_fail(self, get_url, get_tests_data, add_friend_test_case):31 r = user_logic.add_friend(url=urljoin(get_url, "/users/add_friend"), json=get_tests_data[add_friend_test_case])32 assert not r.ok33 def test_add_playlist_success(self, get_url, get_tests_data):34 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])35 user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_success"])36 r = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"])37 assert get_tests_data["add_playlist_success"]["playlist_name"] in r.json()["data"]["playlists"]38 def test_add_playlist_no_password(self, get_url, get_tests_data):39 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])40 r = user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_no_password"])41 assert not r.ok42 def test_add_playlist_twice(self, get_url, get_tests_data):43 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])44 r1 = user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist"])45 r = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"])46 if get_tests_data["add_playlist"]["playlist_name"] in r.json()["data"]["playlists"]:47 r = user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist"])48 assert "error" in r.text49 def test_add_playlist_different_users(self, get_url, get_tests_data):50 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])51 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user2"])52 user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist"])53 user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist2"])54 r = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user2"]["user_name"])55 assert get_tests_data["add_playlist2"]["playlist_name"] in r.json()["data"]["playlists"]56 def test_dont_show_password(self, get_url, get_tests_data):57 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])58 r = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"])59 print(r.text)60 assert "password" not in r.text61 def test_change_password_success(self, get_url, get_tests_data):62 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])63 user_logic.change_password(url=urljoin(get_url, "/users/change_password"), json=get_tests_data["change_password_success"])64 user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_new_password"])65 r = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"])66 print(r.text)67 assert get_tests_data["add_playlist_new_password"]["playlist_name"] in r.json()["data"]["playlists"]68 @pytest.mark.parametrize("change_password_test_case", ["change_password_wrong_password", "change_password_empty"])69 def test_change_password_wrong_password(self, get_url, get_tests_data, change_password_test_case):70 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])71 r = user_logic.change_password(url=urljoin(get_url, "/users/change_password"), json=get_tests_data[change_password_test_case])...

Full Screen

Full Screen

tests_song.py

Source:tests_song.py Github

copy

Full Screen

1from Logic import song_logic, user_logic2from urllib.parse import urljoin3class Test_song:4 def test_add_song_success(self, get_url, get_tests_data):5 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])6 r = song_logic.get_songs_list(url=urljoin(get_url, "/songs/ranked_songs"))7 assert get_tests_data["add_song_success"]["song_title"] in r.__str__()8 def test_songs_less_10(self, get_url, get_tests_data):9 r1 = song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])10 print(r1.text)11 r = song_logic.get_songs_by_rating_less(url=urljoin(get_url, "/songs/ranked_songs"), rating=10)12 print(r.text)13 assert get_tests_data["add_song_success"]["song_title"] in r.text14 def test_new_song_rate_0(self, get_url, get_tests_data):15 r = song_logic.add_song(urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])16 r1 = song_logic.get_songs_by_rating_equal(url=urljoin(get_url, "/songs/ranked_songs"), rating=0)17 assert get_tests_data["add_song_success"]["song_title"] in r1.text18 def test_down_vote_less_0(self, get_url, get_tests_data):19 r = song_logic.add_song(urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])20 r1 = user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])21 r1 = song_logic.song_down_vote(url=urljoin(get_url, "/songs/downvote"), json=get_tests_data["song_down_vote"])22 r = song_logic.get_songs_by_rating_less(url=urljoin(get_url, "/songs/ranked_songs"), rating=0)23 assert r.json()["data"] == []24 def test_up_vote(self, get_url, get_tests_data):25 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])26 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])27 song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote"])28 r = song_logic.get_songs_by_rating_greater(url=urljoin(get_url, "/songs/ranked_songs"), rating=0)29 assert get_tests_data["add_song_success"]["song_title"] in r.json()["data"]30 def test_vote_twice(self, get_url, get_tests_data):31 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])32 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])33 song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote"])34 r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote"])35 print(r.text)36 assert not r.ok37 def test_up_vote_no_password(self, get_url, get_tests_data):38 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])39 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])40 r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote_no_password"])41 print(r.text)42 assert not r.ok43 def test_up_vote_wrong_password(self, get_url, get_tests_data):44 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])45 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])46 r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote_wrong_password"])47 print(r.text)48 assert "error" in r.text49 def test_down_vote_no_password(self, get_url, get_tests_data):50 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])51 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])52 r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_down_vote_no_password"])53 assert not r.ok54 def test_down_vote_wrong_password(self, get_url, get_tests_data):55 user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"])56 song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"])57 r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_down_vote_wrong_password"])...

Full Screen

Full Screen

cotjs.js

Source:cotjs.js Github

copy

Full Screen

1let appNamepdf = $(".appName").val();2let link_urlcddprojet =3 "/" +4 appNamepdf +5 "/interface/tpl/" +6 appNamepdf +7 "/COT/traitementjs/cddprojet.php";8let link_urlcddsimple =9 "/" +10 appNamepdf +11 "/interface/tpl/" +12 appNamepdf +13 "/COT/traitementjs/cddsimple.php";14let link_urlcddessai =15 "/" +16 appNamepdf +17 "/interface/tpl/" +18 appNamepdf +19 "/COT/traitementjs/cddessai.php";20let link_urlcdiessai =21 "/" +22 appNamepdf +23 "/interface/tpl/" +24 appNamepdf +25 "/COT/traitementjs/cdiessai.php";26let link_urlcdisimple =27 "/" +28 appNamepdf +29 "/interface/tpl/" +30 appNamepdf +31 "/COT/traitementjs/cdisimple.php";32let link_urlconsultant =33 "/" +34 appNamepdf +35 "/interface/tpl/" +36 appNamepdf +37 "/COT/traitementjs/consultant.php";38let link_urlconsultantint =39 "/" +40 appNamepdf +41 "/interface/tpl/" +42 appNamepdf +43 "/COT/traitementjs/consultantint.php";44let link_urlstageecole =45 "/" +46 appNamepdf +47 "/interface/tpl/" +48 appNamepdf +49 "/COT/traitementjs/stageecole.php";50let link_urlstagequalification =51 "/" +52 appNamepdf +53 "/interface/tpl/" +54 appNamepdf +55 "/COT/traitementjs/stagequalification.php";56var email=($('.interselectperso').val()).toUpperCase();57$(".print_btn").on("click", function() {58 //get value from simple event of select59 var contratabrege = $(".t_contrat").val();60 let id = $("#numposeidon").val();61 let get_url = "";62 // alert(contratabrege);63 $(".print_btn").hide();64 //alert(contratabrege);65 //affect value of existing data66 $(".print_btn").attr("data-contrat", contratabrege);67 //get value from data-value href after changing script68 let vcontrat = $(".print_btn").data("contrat");69 switch (vcontrat) {70 case "CDD lie au projet":71 get_url = link_urlcddprojet;72 break;73 case "CDD standard":74 get_url = link_urlcddsimple;75 break;76 case "CDD avec essai":77 get_url = link_urlcddessai;78 break;79 case "CDI avec essai":80 get_url = link_urlcdiessai;81 break;82 case "CDI standard":83 get_url = link_urlcdisimple;84 break;85 case "Consultant externe":86 get_url = link_urlconsultant;87 break;88 case "Consultant interne":89 get_url = link_urlconsultantint;90 break;91 case "Stage-ecole":92 get_url = link_urlstageecole;93 break;94 case "Stage professionnel":95 get_url = link_urlstagequalification;96 break;97 default:98 alert("Veuillez choisir le type de contrat et enregister");99 break;100 }101 //alert(id + "****" + get_url);102 //call ajax function103 ajaxPdf(id, get_url,email)104 .then((results) => {105 let newUrlink = xhr.responseURL;106 let oldUrl = $(".print_vbtn").attr("href");107 108 let newUrl = oldUrl.replace("javascript:void(0)", newUrlink);109 // $(".print_btn").text("visualiser");110 $(".print_vbtn").attr("target", "_blank").attr("href", newUrl);111 $(".print_vbtn").show();112 })113 .catch((err) => console.log(err));114});115var xhr = new XMLHttpRequest();116function ajaxPdf(id, url,email) {117 return new Promise((resolve, reject) => {118 $.ajax({119 url: url,120 type: "GET", 121 data: {122 numposeidon: id,123 email: email,124 },125 xhr: function() {126 return xhr;127 },128 success: function(data) {129 resolve(data);130 },131 error: function(error) {132 reject(error);133 },134 });135 });...

Full Screen

Full Screen

context_processors.py

Source:context_processors.py Github

copy

Full Screen

...10 'sso_register_url': add_next(settings.SSO_PROXY_SIGNUP_URL, url),11 'sso_logout_url': add_next(settings.SSO_PROXY_LOGOUT_URL, url),12 'sso_profile_url': settings.SSO_PROFILE_URL,13 }14def get_url(url_name):15 return getattr(settings, url_name, None) or getattr(default_urls, url_name)16def urls_processor(request):17 return {18 'header_footer_urls': {19 'great_home': get_url('GREAT_HOME'),20 'great_export_home': get_url('GREAT_EXPORT_HOME'),21 'custom_page': get_url('CUSTOM_PAGE'),22 # personas23 'new_to_exporting': get_url('EXPORTING_NEW'),24 'occasional_exporter': get_url('EXPORTING_OCCASIONAL'),25 'regular_exporter': get_url('EXPORTING_REGULAR'),26 # guidance/article sections27 'guidance_market_research': get_url('GUIDANCE_MARKET_RESEARCH'),28 'guidance_customer_insight': get_url('GUIDANCE_CUSTOMER_INSIGHT'),29 'guidance_finance': get_url('GUIDANCE_FINANCE'),30 'guidance_business_planning': (31 get_url('GUIDANCE_BUSINESS_PLANNING')32 ),33 'guidance_getting_paid': get_url('GUIDANCE_GETTING_PAID'),34 'guidance_operations_and_compliance': (35 get_url('GUIDANCE_OPERATIONS_AND_COMPLIANCE')36 ),37 # services38 'services_fab': get_url('SERVICES_FAB'),39 'services_soo': get_url('SERVICES_SOO'),40 'services_exopps': get_url('SERVICES_EXOPPS'),41 'services_get_finance': get_url('SERVICES_GET_FINANCE'),42 'services_events': get_url('SERVICES_EVENTS'),43 'info_about': get_url('INFO_ABOUT'),44 'info_contact_us': get_url('INFO_CONTACT_US_DIRECTORY'),45 'info_privacy_and_cookies': get_url('INFO_PRIVACY_AND_COOKIES'),46 'info_terms_and_conditions': get_url('INFO_TERMS_AND_CONDITIONS'),47 'info_dit': get_url('INFO_DIT'),48 }49 }50def header_footer_context_processor(request):51 active_classes = getattr(settings, 'HEADER_FOOTER_CSS_ACTIVE_CLASSES', {})52 return {53 'header_footer_contact_us_url': settings.HEADER_FOOTER_CONTACT_US_URL,54 'header_footer_css_active_classes': active_classes,...

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 pyresttest 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