Tests

functional

test_models.py

pyrally.tests.functional.test_models.test_get_attribute_behaviour_getting_attributes_from_dictionary()[source]

Test __get_attribute__ behaviour works as expected.

Test that BaseRallyModel classes look not only at attributes held within __dict__, but also to keys in the dictionary passed when instantiating.

pyrally.tests.functional.test_models.test_get_attribute_behaviour_dynamically_loading_objects(*args, **keywargs)[source]

Test __get_attribute__ loads objects dynamically if required.

Test that BaseRallyModel classes dynamically load content using Rally API calls when required.

It does this when a dictionary is found at the attribute location in the dictionary given at instatiation and there is a _ref key within that dictionary.

pyrally.tests.functional.test_models.test_get_attribute_behaviour_dynamically_loading_object_lists(*args, **keywargs)[source]

Test __get_attribute__ loads object lists dynamically if required.

Test that BaseRallyModel classes dynamically load sub-content using Rally API calls when required.

It does this when an attribute is given that is defined in sub_objects_dynamic_loader. In such circumstances the mapped key should be used and all sub items in that key fetched from the server.

pyrally.tests.functional.test_models.test_get_attribute_dynamically_loading_objects_no_reference(*args, **keywargs)[source]

Test __get_attribute__ handles `ReferenceNotFoundException s

Test that BaseRallyModel classes handle the case where ReferenceNotFoundException is raised during the call to create_from_ref.

None is returned in these circumstances.

pyrally.tests.functional.test_models.test_set_attr_behaviour()[source]

Test __setattr__ applies changes correctly.

Test that:
  • If the key is present in rally_data, it is updated
  • Otherwise the attribute is updated on the object

unit

test_models

test_get_query_clauses.py

pyrally.tests.unit.test_models.test_get_query_clauses.test_generates_query_strings_correctly()[source]
pyrally.tests.unit.test_models.test_get_query_clauses.test_full_example()[source]
pyrally.tests.unit.test_models.test_get_query_clauses.test_handles_single_clauses()[source]
pyrally.tests.unit.test_models.test_get_query_clauses.test_with_or_simple()[source]
pyrally.tests.unit.test_models.test_get_query_clauses.test_with_or_more_complex()[source]
pyrally.tests.unit.test_models.test_get_query_clauses.test_with_or_more_complex_2()[source]
pyrally.tests.unit.test_models.test_get_query_clauses.test_long_or_set()[source]

test_BaseRallyModel.py

pyrally.tests.unit.test_models.test_BaseRallyModel.get_inherited_class_object()[source]
pyrally.tests.unit.test_models.test_BaseRallyModel.test_create_from_ref_no_errors(*args, **keywargs)[source]

Test create_from_ref() with no API errors.

Test that create_from_ref makes a call to the Rally API and creates returns an instance of the class.

pyrally.tests.unit.test_models.test_BaseRallyModel.test_create_from_ref_with_errors(*args, **keywargs)[source]

Test create_from_ref() with an API error.

Test that create_from_ref raises a ReferenceNotFoundException error when a call to the Rally API results in errors being returned.

pyrally.tests.unit.test_models.test_BaseRallyModel.test_get_all_with_clauses(*args, **keywargs)[source]

Test get_all() with clauses passed in.

Test that:
  • get_all calls get_query_clauses
  • Uses the result to call get_all_results_for_query
  • returns the set of objects as returned by convert_from_query_result
pyrally.tests.unit.test_models.test_BaseRallyModel.test_get_all_without_clauses(*args, **keywargs)[source]

Test get_all() with no clauses passed in.

Test that:
  • get_all does not call get_query_clauses
  • Calls get_all_results_for_query with a blank query.
  • returns the set of objects as returned by convert_from_query_result
pyrally.tests.unit.test_models.test_BaseRallyModel.test_get_all_results_for_query()[source]

Test get_all_results_for_query()

Test that:
  • Calls _get_results_page until all results are fetched.
  • Returns the total of all results pages.
pyrally.tests.unit.test_models.test_BaseRallyModel.test__get_results_page_with_no_errors(*args, **keywargs)[source]

Test _get_results_page() with no errors

Test that:
  • Adds query in if present
  • Returns the QueryResult contents.
pyrally.tests.unit.test_models.test_BaseRallyModel.test__get_results_page_with_errors(*args, **keywargs)[source]

Test _get_results_page() with errors

Test that:
  • Raises an Exception when [QueryResult][Errors] contains content
pyrally.tests.unit.test_models.test_BaseRallyModel.test_convert_from_query_result_with_full_objects(*args, **keywargs)[source]

Test convert_from_query_result() and full objects

Test that:
  • Every result given is converted into the appropriate Python object determined by API_OBJECT_TYPES
  • create_from_ref is not called, meaning that no further API calls are required.
pyrally.tests.unit.test_models.test_BaseRallyModel.test_convert_from_query_result_with_only_ref_objects(*args, **keywargs)[source]

Test convert_from_query_result() with ref objects

Test that:
  • Every result given is converted into the appropriate Python object determined by API_OBJECT_TYPES
  • create_from_ref is called for each reference
pyrally.tests.unit.test_models.test_BaseRallyModel.test_get_by_formatted_id()[source]

Test get_by_formatted_id() works as expected

Test that:
  • The correct clause is created and passed to get_all.
  • Only one item is returned, the first returned back that truly matches the name.
pyrally.tests.unit.test_models.test_BaseRallyModel.test_get_by_formatted_id_no_match()[source]

Test get_by_formatted_id() with no match.

Test that:
  • The correct clause is created and passed to get_all.
  • None is returned if there are no matches.
pyrally.tests.unit.test_models.test_BaseRallyModel.test_title_property()[source]

Test the title property of BaseRallyModel.

test_Defect.py

pyrally.tests.unit.test_models.test_Defect.get_inherited_class_object()[source]
pyrally.tests.unit.test_models.test_Defect.test_get_all_in_kanban_states()[source]

Test get_all_in_kanban_states().

Test that:
  • Uses the correct clause
  • Returns the result of get_all using the clause.

test_Story.py

pyrally.tests.unit.test_models.test_Story.get_inherited_class_object()[source]
pyrally.tests.unit.test_models.test_Story.test_get_all_in_kanban_states()[source]

Test get_all_in_kanban_states().

Test that:
  • Uses the correct clause
  • Returns the result of get_all using the clause.

test_Task.py

pyrally.tests.unit.test_models.test_Task.get_inherited_class_object()[source]
pyrally.tests.unit.test_models.test_Task.test_get_all_for_story()[source]

Test get_all_for_story().

Test that:
  • Uses the correct clause
  • Returns the result of get_all using the clause.

test_client.py

pyrally.tests.unit.test_client.test_initialisation(*args, **keywargs)[source]

Test that RallyAPIClient initialises correctly.

Tests that get_accessor() is called with the appropriate arguments.

pyrally.tests.unit.test_client.test_get_all_entities(*args, **keywargs)[source]

Test that get_all_entities calls the expected method.

Tests that get_all_entities() returns the value returned by method get_all().

pyrally.tests.unit.test_client.test_get_all_in_kanban_states_gets_stories_and_defects(*args, **keywargs)[source]

Test that get_all_in_kanban_states calls the expected methods.

Tests get_all_in_kanban_states().

Tests that:
  • calls Story.get_all_in_kanban_states
  • calls Defect.get_all_in_kanban_states
  • returns a dictionary with all kanban data.
pyrally.tests.unit.test_client.test_get_story_by_name(*args, **keywargs)[source]

Test that get_story_by_formatted_id calls the expected method.

Tests that get_story_by_formatted_id() returns the value returned by method get_by_formatted_id()

pyrally.tests.unit.test_client.test_get_defect_by_name(*args, **keywargs)[source]

Test that get_defect_by_formatted_id calls the expected method.

Tests that get_defect_by_formatted_id() returns the value returned by method get_by_formatted_id()

pyrally.tests.unit.test_client.test_get_entity_by_name(*args, **keywargs)[source]

Test that get_entity_by_formatted_id calls the expected method.

Tests that get_entity_by_formatted_id() returns the value returned by method get_by_formatted_id()

test_rally_access.py

pyrally.tests.unit.test_rally_access.test_get_accessor_returns_created_accessor_if_available(*args, **keywargs)[source]

Test get_accessor returns created.

Test that get_accessor() returns the created accessor if it is available.

pyrally.tests.unit.test_rally_access.test_get_accessor_creates_accessor_if_not_already_created(*args, **keywargs)[source]

Test get_accessor returns created.

Test that get_accessor() creates and returns a RallyAccessor object if it has not already been created.

pyrally.tests.unit.test_rally_access.test_get_accessor_raises_exception_if_not_created_and_no_uname_password(*args, **keywargs)[source]

Test get_accessor raises Exception.

Test that get_accessor() raises an Exception if global ACCESSOR is None and called with no username and password arguments.

pyrally.tests.unit.test_rally_access.test_make_url_safe()[source]

Test that RallyAccessor.make_url_safe() works correctly.

pyrally.tests.unit.test_rally_access.test_make_api_call_full_url_cached(*args, **keywargs)[source]

Test make_api_call with full, cached url.

Tests that make_api_call():
  • looks in the cache first and does not make a urllib call.
  • uses the url given without amendments.
  • makes the url given safe.
pyrally.tests.unit.test_rally_access.test_make_api_call_partial_url_not_cached(*args, **keywargs)[source]

Test make_api_call with partial url, not cached.

Tests that make_api_call():
  • makes a call to the API via urllib.
  • prepends the api_url to the partial url.
  • makes the url given safe.
  • stores the new data in the cache.
pyrally.tests.unit.test_rally_access.test_set_cache_timeout()[source]

Test set_cache_timeout adds the timeout given correctly.

Tests set_cache_timeout().

pyrally.tests.unit.test_rally_access.test_delete_from_cache_removes_correctly()[source]

Test delete_from_cache removes the correct key from the cache.

Tests delete_from_cache().

pyrally.tests.unit.test_rally_access.test_delete_from_cache_handles_missing_key()[source]

Test delete_from_cache handles missing key being deleted.

Tests that delete_from_cache() does not raise an exception when a key is deleted that doesn’t exist.

pyrally.tests.unit.test_rally_access.test_get_cacheable_info()[source]

Test get_cacheable_info.

Tests that get_cacheable_info():
  • returns the right cache key and index
pyrally.tests.unit.test_rally_access.test_get_from_cache_retrieves_correctly()[source]

Test get_from_cache.

Tests that get_from_cache():
  • returns the data at the specified cache location if present
  • returns False if not present
pyrally.tests.unit.test_rally_access.test_get_from_cache_returns_false_if_out_of_date()[source]

Test get_from_cache.

Tests that get_from_cache():
  • returns False if data is out of date
pyrally.tests.unit.test_rally_access.test_set_to_cache_adds_correctly(*args, **keywargs)[source]

Test set_to_cache.

Tests that set_to_cache():
  • adds the given data to the cache.