def test_username_fail_resolve(self):
     story_text = "= a\nb\n-c [@a]"
     dstory = wm.Story(title=" a", story_description="b")
     dtask = wm.Task(description="c  [@a]")
     (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
     compare_django_stories(self, rstory, dstory)
     compare_django_tasks(self, rtasks, [dtask])
Exemple #2
0
def backlog_duplicate_story(request, story_id):
    try:
        story = models.Story.objects.get(id=story_id)
    except models.Story.DoesNotExist:
        raise Http404

    story_new = models.Story()
    story_new.title = story.title
    story_new.story_description = story.story_description
    story_new.moscow = story.moscow
    story_new.is_green = story.is_green
    story_new.tags = story.tags
    story_new.state = 'BACKLOG'
    story_new.time_boxed = story.time_boxed
    story_new.save()

    for task in story.task_set.all():
        task_new = models.Task()
        task_new.description = task.description
        task_new.score = task.score
        task_new.story = story_new
        task_new.owner = task.owner
        task_new.save()

    return HttpResponseRedirect(
        request.GET.get('return-to', reverse('web.index')))
Exemple #3
0
    def create_task_log(self,
                        task_type,
                        hosts,
                        expire_time,
                        content,
                        random_str=None,
                        note=None):
        task_log_obj = models.Task(task_type=task_type,
                                   user=self.request.user,
                                   cmd=content,
                                   files_dir=random_str,
                                   expire_time=int(expire_time),
                                   note=note)
        task_log_obj.save()
        task_log_obj.hosts.add(*hosts)
        #initilize detail logs
        for h in hosts:
            task_log_detail_obj = models.TaskLogDetail(
                child_of_task_id=task_log_obj.id,
                bind_host_id=h.id,
                event_log='',
                result='unknown')
            task_log_detail_obj.save()

        return task_log_obj
 def test_username_resolve(self):
     u = wm.User.objects.create(username="******")
     story_text = "= a\nb\n-c [@andraz]"
     dstory = wm.Story(title=" a", story_description="b")
     dtask = wm.Task(description="c ", owner=u)
     (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
     compare_django_stories(self, rstory, dstory)
     compare_django_tasks(self, rtasks, [dtask])
 def test_django_story_to_text_existing_tags(self):
     dstory = wm.Story(title="story_title",
                       story_description="story_description")
     dtask = wm.Task(description="task description [#abc]")
     res = converter.Converter.django_story_to_text(dstory, [dtask])
     self.assertEqual(
         res, "=story_title\nstory_description\n-task description [#abc]\n")
     dtask.state = "TO_CLOSED"
     res = converter.Converter.django_story_to_text(dstory, [dtask])
     self.assertEqual(
         res,
         "=story_title\nstory_description\n-task description [#abc #done]\n"
     )
    def test_django_story_to_text(self):
        dstory = wm.Story(title="story_title",
                          story_description="story_description")
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\nstory_description\n")

        dstory.is_green = True
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#green]\nstory_description\n")
        dstory.is_green = False

        dstory.is_burning = True
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#fire]\nstory_description\n")
        dstory.is_burning = False

        dstory.moscow = 'M'
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#must]\nstory_description\n")
        dstory.moscow = 'S'
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#should]\nstory_description\n")
        dstory.moscow = 'C'
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#could]\nstory_description\n")
        dstory.moscow = 'W'
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#would]\nstory_description\n")
        dstory.moscow = None

        dstory.tags = "#t1 #t2"
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res, "=story_title\n[#t1 #t2]\nstory_description\n")
        dstory.title = "title with tag #t2"  # here we make sure we don'd duplicate tags if they are already in the title
        res = converter.Converter.django_story_to_text(dstory, [])
        self.assertEqual(res,
                         "=title with tag #t2\n[#t1]\nstory_description\n")
        dstory.tags = None
        dstory.title = "story_title"

        dtask = wm.Task(description="task description")
        res = converter.Converter.django_story_to_text(dstory, [dtask])
        self.assertEqual(
            res, "=story_title\nstory_description\n-task description\n")
        res = converter.Converter.django_story_to_text(dstory, [dtask, dtask])
        self.assertEqual(
            res,
            "=story_title\nstory_description\n-task description\n-task description\n"
        )
Exemple #7
0
def construct_tasks(text, story):
	# Clean task set
	story.task_set.all().delete()
	# Create task set
	for line in text.split('\n'):
		stripped_line = line.replace('-', '').strip()
		task_description = stripped_line[0:stripped_line.find('(')].strip()
		task_score = stripped_line[stripped_line.find('(') + 1:stripped_line.find(')')]

		task_exists = story.task_set.filter(description=task_description, score=task_score).count() == 1

		if not task_exists:
			task = models.Task()
			task.story = story
			task.description = task_description
			task.score = task_score
			task.state = 'TO_WAITING'
			task.save()
Exemple #8
0
    def process(self, request):
        owner = User.objects.get(id=self.cleaned_data['owner'])
        if self.cleaned_data['sprint_id'] > 0:
            sprint = models.Sprint.objects.get(
                id=self.cleaned_data['sprint_id'])
        else:
            sprint = None

        story, created = models.Story.objects.get_or_create(
            id=self.cleaned_data['id'])
        story.title = self.cleaned_data['title']
        story.story_description = self.cleaned_data['story_description']
        story.moscow = 'M'
        story.is_green = False
        story.time_boxed = False
        story.is_burning = True
        if not sprint:
            story.state = 'BACKLOG'
        else:
            story.sprint = sprint
            story.state = 'WAITING'
        story.tags = self.cleaned_data['tags']
        story.created_by = request.user
        story.save()

        if len(story.task_set.all()):
            fire_task = story.task_set.all()[0]
            fire_task.score = self.cleaned_data['score']
            fire_task.owner = owner
        else:
            fire_task = models.Task(description='Complete',
                                    score=self.cleaned_data['score'],
                                    state="TO_WAITING",
                                    owner=owner,
                                    story=story)
        fire_task.save()

        return {
            'completed': True,
            'story': story,
            'fire_task': fire_task,
        }
    def test_django_task_to_text(self):
        dtask = wm.Task(description="task_description")
        res = converter.Converter.django_task_to_task(dtask).to_text()
        self.assertEqual(res, "-task_description")

        dtask.state = "TO_CLOSED"
        res = converter.Converter.django_task_to_task(dtask).to_text()
        self.assertEqual(res, "-task_description[#done]")
        dtask.state = "TO_WORKING"
        res = converter.Converter.django_task_to_task(dtask).to_text()
        self.assertEqual(res, "-task_description[#work]")
        dtask.state = "TO_WAITING"
        res = converter.Converter.django_task_to_task(dtask).to_text()
        self.assertEqual(res, "-task_description")

        dtask.score = 5
        res = converter.Converter.django_task_to_task(dtask).to_text()
        self.assertEqual(res, "-task_description[5]")

        from django.contrib.auth.models import User
        u = User(username="******")
        dtask.owner = u
        res = converter.Converter.django_task_to_task(dtask).to_text()
        self.assertEqual(res, "-task_description[5 @duh]")
Exemple #10
0
    def text_to_django_story(text):
        parser = yacc.get_parser(
            'story')  # we are testing just part of the parser
        text = text.replace("\r\n", "\n")  # convert crlf -> lf
        text = text.strip(
            "\n"
        ) + "\n"  # make sure there are no multiple new lines after the tasks
        story = parser.parse(text, tracking=True)
        if not story:
            raise Exception("Story parsing wasn't successful")
        dstory = wm.Story()
        dstory.title = story.title
        dstory.story_description = story.description
        dstory.state = 'BACKLOG'

        dstory_tags_list = []
        for t in story.tags:
            if "#green" == t:
                dstory.is_green = True
            elif "#fire" == t:
                dstory.is_burning = True
            elif "#timebox" == t:
                dstory.time_boxed = True
            elif "#would" == t:
                dstory.moscow = "W"
            elif "#could" == t:
                dstory.moscow = "C"
            elif "#should" == t:
                dstory.moscow = "S"
            elif "#must" == t:
                dstory.moscow = "M"
            else:
                dstory_tags_list.append(t)
        dstory.tags = " ".join(dstory_tags_list)

        dtasks = []
        for task in story.tasks:
            dtask = wm.Task()
            dtask.score = task.score
            dtask.description = task.text.text
            tags = []
            for t in task.tags:
                if t == "#done":
                    dtask.state = "TO_CLOSED"
                elif t == "#work":
                    dtask.state = "TO_WORKING"
                else:
                    tags.append(t)

            if task.owner:
                # make sure we catch the right errors here
                try:
                    dtask.owner = wm.User.objects.get(username=task.owner[1:])
                except ObjectDoesNotExist:
                    logging.warning(
                        "Could not resolve username: %s, we will add it as regular tag"
                        % task.owner)
                    tags.append(task.owner)

            if tags:
                dtask.description += " [" + " ".join(tags) + "]"

            dtask.story = dstory
            dtasks.append(dtask)

        return (dstory, dtasks)
    def test_text_to_django_story_with_tasks(self):
        story_text = "= a\nb\n-c"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c")
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # empty taskmeta
        story_text = "= a\nb\n-c []"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c ")
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # score taskmeta
        story_text = "= a\nb\n-c [1]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c ", score=1)
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # TEST USER - THIS ONE FAILS UNTIL PANCHO TELLS US WHERE THE @nick CAN BE RESOLVED
        '''
		story_text = "= a\nb\n-c [@a]"
		dstory = wm.Story(title = " a", story_description = "b")
		dtask = wm.Task(description = "c ", score = 1)
		(rstory, rtasks) = converter.Converter.text_to_django_story(story_text)	
		compare_django_stories(self, rstory, dstory)		
		compare_django_tasks(self, rtasks, [dtask])		
		'''

        # tag
        story_text = "= a\nb\n-c [#t1]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c  [#t1]")
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # tag plus score
        story_text = "= a\nb\n-c [#t1 1]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c  [#t1]", score=1)
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # #done
        story_text = "= a\nb\n-c [#done]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c ", state="TO_CLOSED")
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        #done
        story_text = "= a\nb\n-c [#work]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c ", state="TO_WORKING")
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # badass tag combo
        story_text = "= a\nb\n-c [1 #work #t1]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask = wm.Task(description="c  [#t1]", state="TO_WORKING", score=1)
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask])

        # badass tag double combo
        story_text = "= a\nb\n-c [1 #work #t1]\n-d [2 #done]"
        dstory = wm.Story(title=" a", story_description="b")
        dtask1 = wm.Task(description="c  [#t1]", state="TO_WORKING", score=1)
        dtask2 = wm.Task(description="d ", state="TO_CLOSED", score=2)
        (rstory, rtasks) = converter.Converter.text_to_django_story(story_text)
        compare_django_stories(self, rstory, dstory)
        compare_django_tasks(self, rtasks, [dtask1, dtask2])