Python httpretty.GET Examples

The following are 30 code examples of httpretty.GET(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module httpretty , or try the search function .
Example #1
Source File: webelement_test.py    From python-client with Apache License 2.0 6 votes vote down vote up
def test_get_attribute_with_dict(self):
        driver = android_w3c_driver()
        rect_dict = {
            'y': 200,
            'x': 100,
            'width': 300,
            'height': 56
        }
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890/element/element_id/attribute/rect'),
            body=json.dumps({"value": rect_dict})
        )

        element = MobileWebElement(driver, 'element_id', w3c=True)
        ef = element.get_attribute('rect')

        d = httpretty.last_request()

        assert isinstance(ef, dict)
        assert ef == rect_dict 
Example #2
Source File: tests.py    From python-opencage-geocoder with MIT License 6 votes vote down vote up
def testRateLimitExceeded(self):
        httpretty.register_uri(
            httpretty.GET,
            self.geocoder.url,
            body='{"status":{"code":402,"message":"OK"},"thanks":"For using an OpenCage Data API","total_results":0,"licenses":[{"url":"http://creativecommons.org/licenses/by-sa/3.0/","name":"CC-BY-SA"},{"url":"http://opendatacommons.org/licenses/odbl/summary/","name":"ODbL"}],"rate":{"reset":1402185600,"limit":"2500","remaining":0},"results":[],"timestamp":{"created_http":"Sat, 07 Jun 2014 10:38:45 GMT","created_unix":1402137525}}',
            status=402,
            adding_headers={'X-RateLimit-Limit': '2500', 'X-RateLimit-Remaining': '0', 'X-RateLimit-Reset': '1402185600'},
        )

        self.assertRaises(RateLimitExceededError, self.geocoder.geocode, "whatever")

        # check the exception
        try:
            self.geocoder.geocode("whatever")
        except RateLimitExceededError as ex:
            self.assertEqual(str(ex), 'Your rate limit has expired. It will reset to 2500 on 2014-06-08T00:00:00')
            self.assertEqual(ex.reset_to, 2500) 
Example #3
Source File: test_authentication.py    From django-oidc-rp with MIT License 6 votes vote down vote up
def setup(self):
        httpretty.enable()

        self.key = RSAKey(kid='testkey').load(os.path.join(FIXTURE_ROOT, 'testkey.pem'))
        def jwks(_request, _uri, headers):  # noqa: E306
            ks = KEYS()
            ks.add(self.key.serialize())
            return 200, headers, ks.dump_jwks()
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_JWKS_ENDPOINT, status=200, body=jwks)
        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': self.generate_jws(), 'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken', }),
            content_type='text/json')
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_USERINFO_ENDPOINT,
            body=json.dumps({'sub': '1234', 'email': 'test@example.com', }),
            content_type='text/json')

        yield

        httpretty.disable() 
Example #4
Source File: tests.py    From python-opencage-geocoder with MIT License 6 votes vote down vote up
def testDonostia(self):
        httpretty.register_uri(
            httpretty.GET,
            self.geocoder.url,
            body='{"thanks":"For using an OpenCage Data API","status":{"message":"OK","code":200},"rate":{"remaining":2482,"limit":"2500","reset":1402185600},"total_results":7,"results":[{"geometry":{"lat":"43.3213324","lng":"-1.9856227"},"annotations":{},"components":{"postcode":"20001;20002;20003;20004;20005;20006;20007;20008;20009;20010;20011;20012;20013;20014;20015;20016;20017;20018","county":"Donostialdea/Donostia-San Sebasti\u00e1n","state":"Basque Country","country":"Spain","city":"San Sebasti\u00e1n","country_code":"es"},"formatted":"San Sebasti\u00e1n, Donostialdea/Donostia-San Sebasti\u00e1n, 20001;20002;20003;20004;20005;20006;20007;20008;20009;20010;20011;20012;20013;20014;20015;20016;20017;20018, Basque Country, Spain, es","bounds":{"southwest":{"lat":"43.2178373","lng":"-2.086808"},"northeast":{"lng":"-1.8878838","lat":"43.3381344"}}},{"formatted":"Donostia, Irun, Bidasoa Beherea / Bajo Bidasoa, Basque Country, Spain, es","components":{"county":"Bidasoa Beherea / Bajo Bidasoa","state":"Basque Country","country":"Spain","city":"Irun","country_code":"es","road":"Donostia"},"bounds":{"southwest":{"lat":"43.3422299","lng":"-1.8022744"},"northeast":{"lng":"-1.8013452","lat":"43.3449598"}},"geometry":{"lng":"-1.8019153","lat":"43.3432784"},"annotations":{}},{"annotations":{},"geometry":{"lng":"-1.8022744","lat":"43.3422299"},"formatted":"Donostia, Anaka, Irun, Bidasoa Beherea / Bajo Bidasoa, Basque Country, Spain, es","components":{"county":"Bidasoa Beherea / Bajo Bidasoa","state":"Basque Country","country":"Spain","city":"Irun","suburb":"Anaka","country_code":"es","road":"Donostia"},"bounds":{"southwest":{"lng":"-1.8022971","lat":"43.3421635"},"northeast":{"lng":"-1.8022744","lat":"43.3422299"}}},{"geometry":{"lng":"-2.69312049872164","lat":"42.868297"},"annotations":{},"bounds":{"southwest":{"lng":"-2.6933154","lat":"42.8681484"},"northeast":{"lat":"42.8684357","lng":"-2.6929252"}},"formatted":"Donostia kalea, Ibaiondo, Vitoria-Gasteiz, Vitoria-Gasteizko Eskualdea / Cuadrilla de Vitoria, Basque Country, Spain, es","components":{"county":"Vitoria-Gasteizko Eskualdea / Cuadrilla de Vitoria","state":"Basque Country","country":"Spain","city":"Vitoria-Gasteiz","suburb":"Ibaiondo","country_code":"es","road":"Donostia kalea"}},{"bounds":{"southwest":{"lng":"-2.6889534","lat":"42.8620967"},"northeast":{"lat":"42.8623764","lng":"-2.6885774"}},"formatted":"Donostia kalea, Lakua, Vitoria-Gasteiz, Vitoria-Gasteizko Eskualdea / Cuadrilla de Vitoria, Basque Country, Spain, es","components":{"county":"Vitoria-Gasteizko Eskualdea / Cuadrilla de Vitoria","state":"Basque Country","country":"Spain","city":"Vitoria-Gasteiz","suburb":"Lakua","country_code":"es","road":"Donostia kalea"},"geometry":{"lat":"42.8622515","lng":"-2.68876582144679"},"annotations":{}},{"annotations":{},"geometry":{"lat":"51.5146888","lng":"-0.1609307"},"components":{"restaurant":"Donostia","country":"United Kingdom","state_district":"Greater London","country_code":"gb","county":"London","state":"England","suburb":"Marylebone","city":"City of Westminster","road":"Great Cumberland Mews"},"formatted":"Donostia, Great Cumberland Mews, Marylebone, City of Westminster, London, Greater London, England, United Kingdom, gb","bounds":{"northeast":{"lng":"-0.1608807","lat":"51.5147388"},"southwest":{"lat":"51.5146388","lng":"-0.1609807"}}},{"geometry":{"lat":43.31283,"lng":-1.97499},"annotations":{},"bounds":{"northeast":{"lng":"-1.92020404339","lat":"43.3401603699"},"southwest":{"lat":"43.2644081116","lng":"-2.04920697212"}},"formatted":"San Sebastian, Gipuzkoa, Basque Country, Spain, Donostia / San Sebasti\u00e1n","components":{"county":"Gipuzkoa","state":"Basque Country","country":"Spain","town":"San Sebastian","local administrative area":"Donostia / San Sebasti\u00e1n"}}],"timestamp":{"created_unix":1402136556,"created_http":"Sat, 07 Jun 2014 10:22:36 GMT"},"licenses":[{"name":"CC-BY-SA","url":"http://creativecommons.org/licenses/by-sa/3.0/"},{"name":"ODbL","url":"http://opendatacommons.org/licenses/odbl/summary/"}]}',

        )

        results = self.geocoder.geocode("Donostia")
        self.assertTrue(
            any((abs(result['geometry']['lat'] - 43.300836) < 0.05 and abs(result['geometry']['lng'] - -1.9809529) < 0.05) for result in results),
            msg="Bad result"
        )

        # test that the results are in unicode
        self.assertEqual(results[0]['formatted'], six.u('San Sebasti\xe1n, Donostialdea/Donostia-San Sebasti\xe1n, 20001;20002;20003;20004;20005;20006;20007;20008;20009;20010;20011;20012;20013;20014;20015;20016;20017;20018, Basque Country, Spain, es')) 
Example #5
Source File: webdriver_test.py    From python-client with Apache License 2.0 6 votes vote down vote up
def test_get_events_catches_missing_events(self):
        driver = ios_w3c_driver()
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890'),
            body=json.dumps({'value': {}})
        )
        events = driver.events
        assert events == {}
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890'),
            body=json.dumps({})
        )
        events = driver.events
        assert events == {} 
Example #6
Source File: test_backends.py    From django-oidc-rp with MIT License 6 votes vote down vote up
def setup(self):
        httpretty.enable()

        self.key = RSAKey(kid='testkey').load(os.path.join(FIXTURE_ROOT, 'testkey.pem'))
        def jwks(_request, _uri, headers):  # noqa: E306
            ks = KEYS()
            ks.add(self.key.serialize())
            return 200, headers, ks.dump_jwks()
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_JWKS_ENDPOINT, status=200, body=jwks)
        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': self.generate_jws(), 'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken', }),
            content_type='text/json')
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_USERINFO_ENDPOINT,
            body=json.dumps({'sub': '1234', 'email': 'test@example.com', }),
            content_type='text/json')

        yield

        httpretty.disable() 
Example #7
Source File: test_middleware.py    From django-oidc-rp with MIT License 6 votes vote down vote up
def setup(self):
        httpretty.enable()

        self.key = RSAKey(kid='testkey').load(os.path.join(FIXTURE_ROOT, 'testkey.pem'))
        def jwks(_request, _uri, headers):  # noqa: E306
            ks = KEYS()
            ks.add(self.key.serialize())
            return 200, headers, ks.dump_jwks()
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_JWKS_ENDPOINT, status=200, body=jwks)
        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': self.generate_jws(), 'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken', }),
            content_type='text/json')
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_USERINFO_ENDPOINT,
            body=json.dumps({'sub': '1234', 'email': 'test@example.com', }),
            content_type='text/json')

        yield

        httpretty.disable() 
Example #8
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_get_incident_content_error(self):
        """
        Make sure error in content is properly handled
        """
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json.dumps({"error": {"message": "test"}}),
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query={"number": self.mock_incident["number"]}
        )
        self.assertRaises(UnexpectedResponse, r.get_one) 
Example #9
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_get_incident_invalid_query(self):
        """
        Make sure querying by non-dict and non-string doesn't work
        """
        json_body = json.dumps({"result": [{"number": self.mock_incident["number"]}]})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        # Pass query as a `list` , which is invalid
        r = self.client.query(table="incident", query=list())
        self.assertRaises(InvalidUsage, r.get_one) 
Example #10
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_get_sorted(self):
        """
        Make sure order_by generates the expected sysparm_query string
        """
        json_body = json.dumps({"result": [{"number": self.mock_incident["number"]}]})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(table="incident", query={})
        next(r.get_multiple(order_by=["-number", "category"]))

        qs_str = r.last_response.url.split("?")[1]
        qs = dict((x[0], x[1]) for x in [x.split("=") for x in qs_str.split("&")])

        self.assertEqual(
            str(qs["sysparm_query"]), "%5EORDERBYDESCnumber%5EORDERBYcategory"
        ) 
Example #11
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_get_incident_by_string_query(self):
        """
        Make sure fetching by string type query works
        """
        json_body = json.dumps({"result": [{"number": self.mock_incident["number"]}]})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query="nameINincident,task^elementLIKEstate"
        )

        # Make sure we got an incident back with the expected number
        self.assertEqual(r.get_one()["number"], self.mock_incident["number"]) 
Example #12
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_get_content_without_result(self):
        """
        Make sure content without `result` fails
        """
        json_body = json.dumps({})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(table="incident", query={})

        self.assertRaises(MissingResult, r.get_one) 
Example #13
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_get_incident_by_dict_query(self):
        """
        Make sure fetching by dict type query works
        """
        json_body = json.dumps({"result": [{"number": self.mock_incident["number"]}]})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query={"number": self.mock_incident["number"]}
        )

        # Make sure we got an incident back with the expected number
        self.assertEqual(r.get_one()["number"], self.mock_incident["number"]) 
Example #14
Source File: test_package.py    From datapackage-py with MIT License 6 votes vote down vote up
def test_descriptor_dereferencing_uri_remote():
    # Mocks
    httpretty.register_uri(httpretty.GET,
        'http://example.com/schema', body='{"fields": [{"name": "name"}]}')
    httpretty.register_uri(httpretty.GET,
        'https://example.com/dialect', body='{"delimiter": ","}')
    # Tests
    descriptor = {
        'resources': [
            {'name': 'name1', 'data': 'data', 'schema': 'http://example.com/schema'},
            {'name': 'name2', 'data': 'data', 'dialect': 'https://example.com/dialect'},
         ],
    }
    package = Package(descriptor)
    assert package.descriptor['resources'] == list(map(helpers.expand_resource_descriptor, [
        {'name': 'name1', 'data': 'data', 'schema': {'fields': [{'name': 'name'}]}},
        {'name': 'name2', 'data': 'data', 'dialect': {'delimiter': ','}},
    ])) 
Example #15
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_last_response(self):
        json_body = json.dumps({"result": [{"number": self.mock_incident["number"]}]})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(table="incident", query={})
        r.get_one()

        # Make sure we get the expected status code back
        self.assertEqual(r.status_code, 200)

        # Make sure last_response is not None
        self.assertNotEqual(r.last_response, None) 
Example #16
Source File: test_request.py    From pysnow with MIT License 6 votes vote down vote up
def test_last_response_not_executed(self):
        json_body = json.dumps({"result": [{"number": self.mock_incident["number"]}]})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        try:
            str(self.client.query(table="incident", query={}).last_response)
            self.assertFalse(
                "Getting last_response should fail when no `Request` has been executed"
            )
        except NoRequestExecuted:
            pass 
Example #17
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 6 votes vote down vote up
def test_get_all_ok(self):

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='{"objects": [{"id": "3"}], "total": 3}',
                               content_type="application/json",
                               status=200)

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='{"objects": [{"id": "1"}, {"id": "2"}], "total": 3}',
                               content_type="application/json",
                               status=200)

        response = ApiClient().get_all('/service1/', limit=2)
        response_list = list(response)
        assert len(response) == 3
        assert len(response_list) == 3
        assert response_list[0]['id'] == '1'
        assert response_list[1]['id'] == '2'
        assert response_list[2]['id'] == '3' 
Example #18
Source File: system_bars_test.py    From python-client with Apache License 2.0 6 votes vote down vote up
def test_get_system_bars(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890/appium/device/system_bars'),
            body=''' {"value":
                     {"statusBar":
                     {"visible": true, "x": 0, "y": 0, "width": 1080, "height": 1920},
                     "navigationBar":
                     {"visible": true, "x": 0, "y": 0, "width": 1080, "height": 126}}}'''
        )
        d = driver.get_system_bars()

        assert d['statusBar']['visible'] is True
        assert d['statusBar']['x'] == 0
        assert d['statusBar']['y'] == 0
        assert d['statusBar']['width'] == 1080
        assert d['statusBar']['height'] == 1920

        assert d['navigationBar']['visible'] is True
        assert d['navigationBar']['x'] == 0
        assert d['navigationBar']['y'] == 0
        assert d['navigationBar']['width'] == 1080
        assert d['navigationBar']['height'] == 126 
Example #19
Source File: site.py    From anime-downloader with The Unlicense 6 votes vote down vote up
def configure_httpretty(sitedir):
    httpretty.enable()
    dir = Path(f"tests/test_sites/data/test_{sitedir}/")
    data_file = dir / 'data.json'

    data = None
    with open(data_file) as f:
        data = json.load(f)

    for obj in data:
        method = httpretty.POST
        if obj['method'] == 'GET':
            method = httpretty.GET
        with open(dir / obj['file']) as f:
            httpretty.register_uri(
                method,
                obj['url'],
                f.read(),
            ) 
Example #20
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 6 votes vote down vote up
def test_get_all_not_ok_second_page(self):

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='{"error": "deu merda"}',
                               content_type="application/json",
                               status=500)

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='{"objects": [{"id": "1"}, {"id": "2"}], "total": 3}',
                               content_type="application/json",
                               status=200)

        response = ApiClient().get_all('/service1/', limit=2)
        assert len(response) == 3

        with pytest.raises(HTTPException):
            response_list = list(response) 
Example #21
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 5 votes vote down vote up
def test_get_ok(self):

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='[{"id": "1"}]',
                               content_type="application/json",
                               status=200)

        response = ApiClient().get('/service1/')
        assert response.ok
        assert response.data is not None 
Example #22
Source File: webdriver_test.py    From python-client with Apache License 2.0 5 votes vote down vote up
def test_clipboard_with_subclass(self):
        driver = self.android_w3c_driver(SubWebDriver)
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890/context'),
            body='{"value": "NATIVE"}'
        )
        assert driver.current_context == 'NATIVE' 
Example #23
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 5 votes vote down vote up
def test_get_not_ok(self):

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='[{"error": "deu merda"}]',
                               content_type="application/json",
                               status=500)

        response = ApiClient().get('/service1/')
        assert not response.ok 
Example #24
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 5 votes vote down vote up
def test_list_result_set(self):
        data = [{'id': str(n)} for n in range(100)]
        per_page = 2
        total_pages = len(data) / per_page

        def fake_items(start=0):
            httpretty.register_uri(
                httpretty.GET, "http://localhost:8000/service1/",
                body=json.dumps({
                    'objects': data[start:start + per_page],
                    'total': len(data),
                }),
                content_type="application/json",
                status=200,
            )

        fake_items(0)
        result_set = ListResultSet(path='/service1/', limit=per_page)

        assert len(result_set) == len(data)

        # force iter all
        all_items = list(result_set)
        assert len(all_items) == len(data)

        assert len(httpretty_object.latest_requests) == total_pages 
Example #25
Source File: webdriver_test.py    From python-client with Apache License 2.0 5 votes vote down vote up
def test_get_session(self):
        driver = ios_w3c_driver()
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890'),
            body=json.dumps({'value': {'deviceName': 'iPhone Simulator', 'events': {'simStarted': [1234567890]}}})
        )
        session = driver.session
        assert session['deviceName'] == 'iPhone Simulator'
        assert session['events']['simStarted'] == [1234567890] 
Example #26
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 5 votes vote down vote up
def test_get_not_ok_not_json(self):

        httpretty.register_uri(httpretty.GET, "http://localhost:8000/service1/",
                               body='error: "deu merda"',
                               content_type="text/html",
                               status=500)

        response = ApiClient().get('/service1/')
        assert not response.ok 
Example #27
Source File: webdriver_test.py    From python-client with Apache License 2.0 5 votes vote down vote up
def test_get_events(self):
        driver = ios_w3c_driver()
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890'),
            body=json.dumps({'value': {'events': {'simStarted': [1234567890]}}})
        )
        events = driver.events
        assert events['simStarted'] == [1234567890] 
Example #28
Source File: test_http_client.py    From marvin-python-toolbox with Apache License 2.0 5 votes vote down vote up
def test_full_url_path(self):

        httpretty.register_uri(httpretty.GET, "http://localhost:9999/service_full/",
                               body='[{"id": "1"}]',
                               content_type="application/json",
                               status=200)

        response = ApiClient().get('http://localhost:9999/service_full/')
        assert response.ok
        assert response.data is not None 
Example #29
Source File: ime_test.py    From python-client with Apache License 2.0 5 votes vote down vote up
def test_active_ime_engine(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890/ime/active_engine'),
            body=json.dumps({'value': 'com.android.inputmethod.latin/.LatinIME'})
        )
        assert driver.active_ime_engine == 'com.android.inputmethod.latin/.LatinIME' 
Example #30
Source File: webdriver_test.py    From python-client with Apache License 2.0 5 votes vote down vote up
def test_clipboard_with_subsubclass(self):
        driver = self.android_w3c_driver(SubSubWebDriver)
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890/context'),
            body='{"value": "NATIVE"}'
        )
        assert driver.current_context == 'NATIVE'