gdata.test_config
index
/usr/local/svn/gdata-python-client/src/gdata/test_config.py

# Copyright (C) 2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

 
Modules
       
atom
gdata
gdata.test_config_template

 
Functions
       
close_client(client)
Saves the recoded responses to a temp file if the config file allows.
 
This should be called in the unit test's tearDown method.
 
Checks to see if settings.CACHE_RESPONSES is True, to make sure we only
save sessions to repeat if the user desires.
close_service(service)
configure_cache(client, test_name)
Loads or begins a cached session to record HTTP traffic.
 
Should be called at the beginning of each test method.
 
Args:
  client: a gdata.GDClient whose http_client member has been replaced
          with a atom.mock_http_core.MockHttpClient so that repeated
          executions can used cached responses instead of contacting
          the server.
  test_name: str The name of this test method. Examples: 
             'TestClass.test_x_works', 'TestClass.test_crud_operations'.
             This is used to name the recording of the HTTP requests and
             responses, so it should be unique to each test method in the
             test case.
configure_client(client, config, case_name)
Sets up a mock client which will reuse a saved session.
 
Should be called during setUp of each unit test.
 
Handles authentication to allow the GDClient to make requests which
require an auth header.
 
Args:
  client: a gdata.GDClient whose http_client member should be replaced
          with a atom.mock_http_core.MockHttpClient so that repeated
          executions can used cached responses instead of contacting
          the server.
  config: a dict of test specific settings from the gdata.test_config
          module. Examples can be found in gdata.test_config_template
          look at BloggerConfig and ContactsConfig.
  case_name: str The name of the test case class. Examples: 'BloggerTest',
             'ContactsTest'. Used to save a session
             for the ClientLogin auth token request, so the case_name
             should be reused if and only if the same username, password,
             and service are being used.
configure_service(service, config, case_name)
Sets up a mock GDataService v1 client to reuse recorded sessions.
 
Should be called during setUp of each unit test. This is a duplicate of
configure_client, modified to handle old v1 service classes.
configure_service_cache(service, test_name)
Loads or starts a session recording for a v1 Service object.
 
Duplicates the behavior of configure_cache, but the target for this
function is a v1 Service object instead of a v2 Client.