@@ -0,0 +1,2869 @@
+import pytest%0Afrom pyservice import Client%0A%0A%0Adef test_load_api_defaults():%0A    ''' Missing api values are loaded '''%0A    api = %7B%0A        %22version%22: %222.0%22,%0A        %22not_provided%22: %22value%22,%0A        %22operations%22: %5B%22foo%22%5D%0A    %7D%0A    service = Client(**api)%0A%0A    # Ensure given values aren't blown away%0A    for key, value in api.items():%0A        assert service.api%5Bkey%5D == value%0A%0A    expected_keys = %5B%0A        %22version%22,%0A        %22timeout%22,%0A        %22debug%22,%0A        %22endpoint%22,%0A        %22operations%22,%0A        %22exceptions%22%0A    %5D%0A    for key in expected_keys:%0A        assert key in service.api%0A%0A%0Adef test_client_builds_path_format():%0A    '''%0A    endpoint.client_pattern should be a format string containing %7Boperation%7D%0A    '''%0A    api = %7B%22endpoint%22: %7B%0A        %22pattern%22: %22/test/%7Boperation%7D%22,%0A        %22scheme%22: %22http%22,%0A        %22host%22: %22localhost%22,%0A        %22port%22: 8080%0A        %7D%0A    %7D%0A    service = Client(**api)%0A    pattern = service.api%5B%22endpoint%22%5D%5B%22client_pattern%22%5D%0A    assert pattern == %22http://localhost:8080/test/%7Boperation%7D%22%0A%0A%0Adef test_client_no_plugins(client):%0A    ''' no built-in plugins '''%0A    assert not client.plugins%5B%22request%22%5D%0A    assert not client.plugins%5B%22operation%22%5D%0A%0A%0Adef test_client_dynamic_exceptions(client):%0A    ''' client provides a dynamic exception factory '''%0A    assert client.exceptions.FooError%0A    assert client.exceptions.ValueError is ValueError%0A%0A%0Adef test_unknown_plugin_scope(client):%0A    ''' request and operation are the only scopes '''%0A    with pytest.raises(ValueError):%0A        client.plugin(scope=%22not a real scope%22)%0A%0A%0Adef test_plugin_binding(client):%0A    ''' func can be passed to client.plugin or deferred '''%0A    def plugin():%0A        pass%0A%0A    client.plugin(scope='request', func=plugin)%0A%0A    def another_plugin():%0A        pass%0A%0A    client.plugin(scope='operation')(another_plugin)%0A%0A    assert plugin in client.plugins%5B'request'%5D%0A    assert another_plugin in client.plugins%5B'operation'%5D%0A%0A%0Adef test_client_unknown_operation(client):%0A    ''' ValueError for an unknown operation '''%0A    with pytest.raises(ValueError):%0A        client.operation(%22unknown operation%22)%0A%0A%0Adef test_operation_binding_caches(api, observe):%0A    ''' operation lookup is cached '''%0A    class ObserverClient(Client):%0A        def __getattr__(self, *args, **kwargs):%0A            nonlocal calls%0A            calls += 1%0A            return super().__getattr__(*args, **kwargs)%0A%0A    client = ObserverClient(**api)%0A    calls = 0%0A%0A    client.foo%0A    client.foo%0A%0A    assert calls == 1%0A%0A%0Adef test_operation_calls_process(client):%0A    return_value = %22Hello, World!%22%0A    process_args = %5B%5D%0A%0A    def process(*args):%0A        nonlocal process_args, return_value%0A        process_args.extend(args)%0A        return return_value%0A    client.__process__ = process%0A%0A    result = client.foo(key=%22value%22)%0A    assert result == return_value%0A    assert process_args == %5B%22foo%22, %7B%22key%22: %22value%22%7D%5D%0A

Add basic Client tests