Best Python code snippet using mailosaur-python_python
test_yolp.py
Source:test_yolp.py
2from __future__ import unicode_literals, print_function3import pytest4from yolp import YOLP, YOLPError5class TestGeocode(object):6 def test_unauthorized(self):7 yolp = YOLP('INVALID_APP_ID')8 with pytest.raises(YOLPError):9 yolp.geocode('æ±äº¬é½å代ç°åºä¸¸ã®å
ä¸ä¸ç®')10 @pytest.mark.parametrize('address', [11 'åå¤å±çæç¥å¸ãªãã1-1-2',12 'æ¸è°·çæ±äº¬åºè¥¿3-19-2',13 'ã»ãããã',14 ])15 def test_invalid_address(self, yolp, address):16 data = yolp.geocode(address)17 assert isinstance(data, list)18 assert len(data) == 019 # @pytest.mark.parametrize('params', [20 # {'query': 'æ±äº¬é½å代ç°åºä¸¸ã®å
ä¸ä¸ç®', 'lat': -100.0, 'lon': -203.0},21 # ])22 # def test_invalid_params(self, yolp, params):23 # with pytest.raises(YOLPError) as errinfo:24 # yolp.geocode(**params)25 # assert errinfo.value.code == 20426 @pytest.mark.parametrize('address', ['æ±äº¬é½å代ç°åºä¸¸ã®å
ä¸ä¸ç®'])27 def test_valid_address(self, yolp, address):28 data = yolp.geocode(address)29 assert isinstance(data, list)30 assert len(data) >= 131class TestReverseGeocode(object):32 def test_unauthorized(self):33 yolp = YOLP('INVALID_APP_ID')34 with pytest.raises(YOLPError):35 yolp.reverse_geocode(35.674891, 139.763153)36 @pytest.mark.parametrize('lat, lon', [37 (0.0, 0.0),38 (25.0, 120.0),39 ])40 def test_unknown_point(self, yolp, lat, lon):41 data = yolp.reverse_geocode(lat, lon)42 assert isinstance(data, list)43 assert len(data) == 044 @pytest.mark.parametrize('params', [45 {'lat': -100.0, 'lon': -203.0},46 ])47 def test_invalid_params(self, yolp, params):48 with pytest.raises(YOLPError) as errinfo:49 yolp.reverse_geocode(**params)50 assert errinfo.value.code == 100451 @pytest.mark.parametrize('lat, lon', [(35.674891, 139.763153)])52 def test_valid_point(self, yolp, lat, lon):53 data = yolp.reverse_geocode(lat, lon)54 assert isinstance(data, list)55 assert len(data) >= 156class TestDistance(object):57 def test_unauthorized(self):58 yolp = YOLP('INVALID_APP_ID')59 with pytest.raises(YOLPError):60 yolp.distance((35.680243, 139.767448), (35.674891, 139.763153))61 @pytest.mark.parametrize('start, end', [62 ((-100.0, -203.0), (-100.0, -204.0),),63 ])64 def test_invalid_points(self, yolp, start, end):65 with pytest.raises(YOLPError) as errinfo:66 yolp.distance(start, end)67 assert errinfo.value.code == 40068 @pytest.mark.parametrize('start, end', [69 ((35.680243, 139.767448), (35.674891, 139.763153),),70 ])71 def test_valid_points(self, yolp, start, end):72 data = yolp.distance(start, end)73 assert isinstance(data, list)74 assert len(data) >= 175class TestZipCode(object):76 def test_unauthorized(self):77 yolp = YOLP('INVALID_APP_ID')78 with pytest.raises(YOLPError):79 yolp.zipcode('100-0005')80 @pytest.mark.parametrize('zipcode', [81 '000-0000',82 '999-9999',83 ])84 def test_invalid_zipcode(self, yolp, zipcode):85 data = yolp.zipcode(zipcode)86 assert isinstance(data, list)87 assert len(data) == 088 @pytest.mark.parametrize('zipcode', ['100-0005'])89 def test_valid_zipcode(self, yolp, zipcode):90 data = yolp.zipcode(zipcode)91 assert isinstance(data, list)92 assert len(data) >= 193class TestPlace(object):94 def test_unauthorized(self):95 yolp = YOLP('INVALID_APP_ID')96 with pytest.raises(YOLPError):97 yolp.place(35.674891, 139.763153)98 @pytest.mark.parametrize('lat, lon', [99 ('a', 'b'),100 (0.0, 0.0),101 (25.0, 120.0),102 (-100.0, -203.0),103 ])104 def test_unknown_point(self, yolp, lat, lon):105 data = yolp.place(lat, lon)106 assert isinstance(data, dict)107 assert len(data['Area']) == 0108 @pytest.mark.parametrize('lat, lon', [(35.674891, 139.763153)])109 def test_valid_point(self, yolp, lat, lon):110 data = yolp.place(lat, lon)111 assert isinstance(data, dict)112 assert len(data['Area']) >= 1113class TestContents(object):114 def test_unauthorized(self):115 yolp = YOLP('INVALID_APP_ID')116 with pytest.raises(YOLPError):117 yolp.contents('æ±äº¬é½å代ç°åºä¸¸ã®å
ä¸ä¸ç®')118 @pytest.mark.parametrize('address', ['ãsã jlks'])119 def test_invalid_address(self, yolp, address):120 data = yolp.contents(address)121 assert isinstance(data, list)122 assert len(data) == 0123 @pytest.mark.parametrize('address', ['æ±äº¬é½å代ç°åºä¸¸ã®å
ä¸ä¸ç®'])124 def test_contents(self, yolp, address):125 data = yolp.contents(address)126 assert isinstance(data, list)127 assert len(data) >= 1128class TestDatum(object):129 def test_unauthorized(self):130 yolp = YOLP('INVALID_APP_ID')131 with pytest.raises(YOLPError):132 yolp.datum((35.680243, 139.767448))133 @pytest.mark.parametrize('points', [134 (('a', 'b'),),135 ])136 def test_invalid_points(self, yolp, points):137 with pytest.raises(YOLPError):138 yolp.datum(*points, datum='tky')139 @pytest.mark.parametrize('points', [140 ((35.680243, 139.767448),),141 ((35.680243, 139.767448), (35.674891, 139.763153)),142 ])143 def test_valid_points(self, yolp, points):144 data = yolp.datum(*points, datum='tky')145 assert isinstance(data, list)146 assert len(data) == len(points)147class TestAltitude(object):148 def test_unauthorized(self):149 yolp = YOLP('INVALID_APP_ID')150 with pytest.raises(YOLPError):151 yolp.altitude((35.680243, 139.767448))152 @pytest.mark.parametrize('points', [153 (('a', 'b'),),154 ])155 def test_invalid_points(self, yolp, points):156 with pytest.raises(YOLPError):157 yolp.altitude(*points)158 @pytest.mark.parametrize('points', [159 ((35.680243, 139.767448),),160 ((35.680243, 139.767448), (35.674891, 139.763153)),161 ])162 def test_altitude(self, yolp, points):...
unauthorized.py
Source:unauthorized.py
1from rest_framework import status2from test_runners import status_code as status_test3class Test_unauthorized( status_test.Test_status_code ):4 expected_status_code = status.HTTP_401_UNAUTHORIZED5 def setUp( self ):6 token = self.get_token()7 if token is not None:8 self.client.credentials( HTTP_AUTHORIZATION=str( token ) )9 def get_token( self ):10 pass11class Test_list( Test_unauthorized, status_test.Test_list ):12 pass13class Test_retrieve( Test_unauthorized, status_test.Test_retrieve ):14 pass15class Test_create( Test_unauthorized, status_test.Test_create ):...
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!!