def test_story_flow(): """Test that we can do all the things we expect on a story.""" if 'rally1' in settings.BASE_URL: raise Exception('This test should NOT be run against a live working ' 'version of Rally. Please change your settings to ' 'point to a community version (ie ' 'community.rallydev.com).') rally_access.ACCESSOR = None rally_access.MEM_CACHE.clear() RallyAPIClient(settings.RALLY_USERNAME, settings.RALLY_PASSWORD, settings.BASE_URL) story_name = 'Dummy Story Auto Created: {0}'.format(time.time()) # Create a story s = Story({ 'DefectStatus': "NONE", 'ScheduleState': "Defined", 'TaskStatus': 'NONE', 'TestCaseStatus': 'NONE', 'Name': story_name, }) s.update_rally() # Check it has been created assert_true('US' in s.FormattedID) assert_equal(s.title, story_name) assert_true(s.ref) # Edit the story new_name = "Changed Story Name: {0}".format(time.time()) s.update(Name=new_name) s.update_rally() # Check that the edit has taken place # Delete the cache so we can be sure we're getting it from Rally. rally_access.MEM_CACHE.clear() s2 = Story.get_by_formatted_id(s.FormattedID) assert_equal(s2.Name, new_name) # Delete the story s2.delete() # Delete the cache so we can be sure we're getting it from Rally. rally_access.MEM_CACHE.clear() # Check the story no longer exists. s3 = Story.get_by_formatted_id(s.FormattedID) assert_equal(s3, None)
def get_story_by_name(self, story_name): """ Return the story with the name ``story_name``. :param story_name: The USXXX story id of the story. :returns: A ``Story`` object. """ return Story.get_by_name(story_name)
def get_story_by_formatted_id(self, story_id): """ Return the story with the id ``story_id``. :param story_id: The USXXX story id of the story. :returns: A ``Story`` object. """ return Story.get_by_formatted_id(story_id)
def get_all_in_kanban_state(self, kanban_state): """ Get all stories and defects in the given ``kanban_state``. :param kanban_state: The kanban state to search for. :returns: A dictionary containing keys for ``stories`` and ``defects``, and values of lists of associated ``Story`` and ``Defect`` objects. """ stories = Story.get_all_in_kanban_state(kanban_state) defects = Defect.get_all_in_kanban_state(kanban_state) return {'stories': stories, 'defects': defects}
def get_all_in_kanban_states(self, kanban_states): """ Get all stories and defects in the given ``kanban_state``. :param kanban_state: A list of kanban states to search on. :returns: A dictionary containing keys for ``stories`` and ``defects``, and values of lists of associated ``Story`` and ``Defect`` objects. """ stories = Story.get_all_in_kanban_states(kanban_states) defects = Defect.get_all_in_kanban_states(kanban_states) return {'stories': stories, 'defects': defects}
def test_story_flow(): """Test that we can do all the things we expect on a story.""" if 'rally1' in settings.BASE_URL: raise Exception('This test should NOT be run against a live working ' 'version of Rally. Please change your settings to ' 'point to a community version (ie ' 'community.rallydev.com).') rally_access.ACCESSOR = None rally_access.MEM_CACHE.clear() RallyAPIClient(settings.RALLY_USERNAME, settings.RALLY_PASSWORD, settings.BASE_URL) story_name = 'Dummy Story Auto Created: {0}'.format(time.time()) # Create a story s = Story({'DefectStatus': "NONE", 'ScheduleState': "Defined", 'TaskStatus': 'NONE', 'TestCaseStatus': 'NONE', 'Name': story_name, }) s.update_rally() # Check it has been created assert_true('US' in s.FormattedID) assert_equal(s.title, story_name) assert_true(s.ref) # Edit the story new_name = "Changed Story Name: {0}".format(time.time()) s.update(Name=new_name) s.update_rally() # Check that the edit has taken place # Delete the cache so we can be sure we're getting it from Rally. rally_access.MEM_CACHE.clear() s2 = Story.get_by_formatted_id(s.FormattedID) assert_equal(s2.Name, new_name) # Delete the story s2.delete() # Delete the cache so we can be sure we're getting it from Rally. rally_access.MEM_CACHE.clear() # Check the story no longer exists. s3 = Story.get_by_formatted_id(s.FormattedID) assert_equal(s3, None)
from pyrally.models import Story, Artifact, Task, User rac = RallyAPIClient(settings.RALLY_USERNAME, settings.RALLY_PASSWORD, settings.BASE_URL) rac.rally_access.default_cache_timeout = 0 print settings.BASE_URL, settings.RALLY_USERNAME def sort_by_rank(story_a, story_b): return cmp(story_a.Rank, story_b.Rank) from pyrally.models import get_query_clauses stories = Story.get_all_in_iteration("Sprint 101") stories.sort(sort_by_rank) for s in stories: print s.FormattedID, s.Name, s.Rank, s.KanbanState story_to_change = stories[1] if story_to_change.KanbanState == 'In Development': state = 'In RC review' else: state = 'In Development' story_to_change.KanbanState = state del story_to_change.rally_data['Rank'] story_to_change.update_rally() print 'AFTER'
from pyrally.client import RallyAPIClient from pyrally import settings from pyrally.models import Story, Artifact, Task, User rac = RallyAPIClient(settings.RALLY_USERNAME, settings.RALLY_PASSWORD, settings.BASE_URL) rac.rally_access.default_cache_timeout = 0 print settings.BASE_URL, settings.RALLY_USERNAME def sort_by_rank(story_a, story_b): return cmp(story_a.Rank, story_b.Rank) from pyrally.models import get_query_clauses stories = Story.get_all_in_iteration("Sprint 101") stories.sort(sort_by_rank) for s in stories: print s.FormattedID, s.Name, s.Rank, s.KanbanState story_to_change = stories[1] if story_to_change.KanbanState == 'In Development': state = 'In RC review' else: state = 'In Development' story_to_change.KanbanState = state del story_to_change.rally_data['Rank'] story_to_change.update_rally() print 'AFTER'
from pyrally.settings import KANBAN_STATES from pyrally.client import RallyAPIClient from pyrally import settings from pyrally.models import Story rac = RallyAPIClient(settings.RALLY_USERNAME, settings.RALLY_PASSWORD) all_stories = Story.get_all() print len(all_stories) story = rac.get_story_by_name('us524') print story print story.Owner.DisplayName story = rac.get_story_by_name('us124') print story.__dict__ print story.Owner print story.title dict_obj = rac.get_all_in_kanban_state('In QA Testing') print dict_obj story = rac.get_entity_by_name('us524') defect = rac.get_entity_by_name('de92') print story.title print defect.title story = rac.get_story_by_name('us524') print story.Description print story.title print story.FormattedID print story.Blocked