예제 #1
0
    def test_create_new_task(self):
        """
        Test Create new task
        """
        self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key)
        team = TaskTeamFactory.create()
        project = TaskProjectFactory.create()
        type = TaskTypeFactory.create()

        task_data = {"name": "Sample Task",
                     "short_description": "Task Desc",
                     "instructions": "Task Inst",
                     "prerequisites": "Task Prerequisite",
                     "execution_time": 30,
                     "is_draft": False,
                     "is_invalid": False,
                     "project": project.name,
                     "team": team.name,
                     "type": type.name,
                     "repeatable": False,
                     "start_date": None,
                     "end_date": None,
                     "difficulty": 1,
                     "why_this_matters": "Task matters",
                     "keyword_set": [{"name": "testing"}, {"name": "mozwebqa"}],
                     "taskattempt_set": [{"user": self.client_user.email, "state": 0}],
                     "owner": self.client_user.email}

        response = self.client.post(self.uri, task_data, format='json')
        self.assert_response_status(response, status.HTTP_201_CREATED)
        response_data = json.loads(response.content)
        assert_greater(response_data['id'], 0)
        del response_data['id']
        eq_(sorted(response_data), sorted(task_data))
예제 #2
0
    def create_task(self, creator):
        team = TaskTeamFactory.create()
        project = TaskProjectFactory.create()
        type = TaskTypeFactory.create()

        return TaskFactory.create(team=team, project=project, type=type,
                                  creator=creator, owner=creator)