def test_cannotSetRequestorForStory(self): story = Story() requestor = "me" story.SetRequestedBy(requestor) item = PivotalTrackerItem(story) item.withRequestor(PivotalUser(requestor)) self.assertEqual([], item.decoratedStory().UPDATE_FIELDS)
def handle_message(self, campfire, room, message, speaker): project_name = room.data['name'] tracker = Tracker(self.map, self.auth) body = message['body'] if not body: return m = re.match( 'pt story create "(?P<title>.*)" "(?P<description>.*)" (?P<type>.*)$', body) if m: story = Story() story.SetRequestedBy(speaker['user']['name']) story.SetName(m.group('title')) story.SetDescription(m.group('description')) story.SetStoryType(m.group('type')) new_story = tracker.AddNewStory(story) self.speak_new_story(room, new_story, speaker) return m = re.match( "pt getmine (?P<state>started|finished|delivered|accepted|rejected|unstarted|unscheduled)$", body) if m: stories = tracker.GetStories( 'owner:"%s" state:%s' % (speaker['user']['name'], m.group('state'))) if len(stories) > 0: speak_text = "%s: Here are your stories:\r\n" % speaker[ 'user']['name'] room.speak(speak_text) speak_text = '' for story in stories: speak_text += '[#%i] "%s" (%s)\r\n\r\n' % ( story.GetStoryId(), story.GetName(), story.GetUrl()) room.paste(speak_text) else: speak_text = "%s: You have no stories matching that query." % speaker[ 'user']['name'] room.speak(speak_text) return m = re.match("pt start #?(?P<id>\d+)$", body) if m: story = tracker.GetStory(int(m.group('id'))) story.SetCurrentState('started') story.SetOwnedBy(speaker['user']['name']) tracker.UpdateStory(story) room.speak("%s: [#%i] started by you! Get to work!" % (speaker['user']['name'], story.GetStoryId())) return m = re.match( "pt (?P<command>start|tell) next (?P<story_type>bug|feature|chore)(\s+)?(?P<mine>mine)?", body) if m: filter = "type:%s state:unstarted" % m.group('story_type') if m.group('mine') == 'mine': filter += ' owner:"%s"' % speaker['user']['name'] try: next = tracker.GetStories(filter)[0] except IndexError: room.speak("%s: There were no stories matching your query." % speaker['user']['name']) if m.group('command') == 'start': next.SetCurrentState('started') next.SetOwnedBy(speaker['user']['name']) tracker.UpdateStory(next) room.speak("%s: [#%i] started by you! Get to work!" % (speaker['user']['name'], next.GetStoryId())) elif m.group('command') == 'tell': room.speak("%s: [#%i] %s (%s)" % (speaker['user']['name'], next.GetStoryId(), next.GetName(), next.GetUrl())) return