コード例 #1
0
ファイル: link.py プロジェクト: Dr-Rakcha/stalker-pyramid
def upload_files(request):
    """uploads a list of files to the server, creates Link instances in server
    and returns the created link ids with a response to let the front end
    request a linkage between the entity and the uploaded files
    """
    # decide if it is single or multiple files
    file_params = request.POST.getall('file')
    logger.debug('file_params: %s ' % file_params)

    try:
        new_links = upload_files_to_server(request, file_params)
    except IOError as e:
        c = StdErrToHTMLConverter(e)
        response = Response(c.html())
        response.status_int = 500
        transaction.abort()
        return response
    else:
        # store the link object
        DBSession.add_all(new_links)

        logger.debug('created links for uploaded files: %s' % new_links)

        return {
            'link_ids': [link.id for link in new_links]
        }
コード例 #2
0
    def test_deleting_time_log_for_a_task_with_status_complete(self):
        """testing if it is not allowed to delete a time log of a task with
        status completed
        """
        # TODO: This is also testing some functionality from view.task, slit it
        # create two new task
        task0 = Task(
            name='Test Task 0',
            project=self.proj1,
            status_list=self.task_status_list
        )
        task1 = Task(
            name='Test Task 1',
            parent=task0,
            status_list=self.task_status_list,
            resources=[self.user1]
        )
        task1.status = self.status_wip
        DBSession.add_all([task0, task1])
        DBSession.commit()
        DBSession.flush()
        transaction.commit()

        self.assertEqual(task0.status, self.status_new)
        self.assertEqual(task1.status, self.status_wip)

        # now add a time log for task3 through create_time_log view
        request = testing.DummyRequest()

        # patch get_logged_in_user
        admins = Group.query.filter(Group.name == 'admins').first()
        self.user1.groups.append(admins)
        m = mocker.Mocker()
        obj = m.replace("stalker_pyramid.views.auth.get_logged_in_user")
        obj(request)
        m.result(self.user1)
        m.count(1, 1000000000)
        m.replay()
        request.route_url = lambda x, id=1: 'view_user'

        request.params['task_id'] = task1.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 19 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 19 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)

        # set it to complete
        task1.status = self.status_cmpl

        # now try to remove it
        request.matchdict['id'] = task1.time_logs[0].id
        response = time_log.delete_time_log(request)
        self.assertEqual(response.status_int, 500)
        self.assertEqual(
            response.body,
            'Error: You can not delete a TimeLog of a Task with status CMPL'
        )
コード例 #3
0
ファイル: link.py プロジェクト: Dr-Rakcha/stalker-pyramid
def assign_reference(request):
    """assigns the link to the given entity as a new reference
    """
    link_ids = get_multi_integer(request, 'link_ids[]')
    removed_link_ids = get_multi_integer(request, 'removed_link_ids[]')
    entity_id = request.params.get('entity_id', -1)

    entity = Entity.query.filter_by(id=entity_id).first()
    links = Link.query.filter(Link.id.in_(link_ids)).all()
    removed_links = Link.query.filter(Link.id.in_(removed_link_ids)).all()

    # Tags
    tags = get_tags(request)

    logged_in_user = get_logged_in_user(request)

    logger.debug('link_ids      : %s' % link_ids)
    logger.debug('links         : %s' % links)
    logger.debug('entity_id     : %s' % entity_id)
    logger.debug('entity        : %s' % entity)
    logger.debug('tags          : %s' % tags)
    logger.debug('removed_links : %s' % removed_links)

    # remove all the removed links
    for removed_link in removed_links:
        # no need to search for any linked tasks here
        DBSession.delete(removed_link)

    if entity and links:
        entity.references.extend(links)

        # assign all the tags to the links
        for link in links:
            link.tags.extend(tags)
            # generate thumbnail
            thumbnail = generate_thumbnail(link)
            link.thumbnail = thumbnail
            thumbnail.created_by = logged_in_user
            DBSession.add(thumbnail)

        DBSession.add(entity)
        DBSession.add_all(links)

    # return new links as json data
    # in response text
    return [
        {
            'id': link.id,
            'full_path': link.full_path,
            'original_filename': link.original_filename,
            'thumbnail': link.thumbnail.full_path
            if link.thumbnail else link.full_path,
            'tags': [tag.name for tag in link.tags]
        } for link in links
    ]
コード例 #4
0
    def setUp(self):
        """set up the test
        """
        # we need a database
        db.setup(self.config)
        db.init()

        # replace datetime now function

        # create departments
        self.test_dep1 = Department(name='Dep1')
        self.test_dep2 = Department(name='Dep2')

        # create resources
        self.test_user1 = User(
            login='******',
            name='User1',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep1]
        )
        DBSession.add(self.test_user1)

        self.test_user2 = User(
            login='******',
            name='User2',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep1]
        )
        DBSession.add(self.test_user2)

        self.test_user3 = User(
            login='******',
            name='User3',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep2]
        )
        DBSession.add(self.test_user3)

        self.test_user4 = User(
            login='******',
            name='User4',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep2]
        )
        DBSession.add(self.test_user4)

        # user with two departments
        self.test_user5 = User(
            login='******',
            name='User5',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep1, self.test_dep2]
        )
        DBSession.add(self.test_user5)

        # user with no departments
        self.test_user6 = User(
            login='******',
            name='User6',
            email='*****@*****.**',
            password='******'
        )
        DBSession.add(self.test_user6)

        # repository
        self.test_repo = Repository(
            name='Test Repository',
            linux_path='/mnt/T/',
            windows_path='T:/',
            osx_path='/Volumes/T/'
        )
        DBSession.add(self.test_repo)

        # statuses
        self.test_status1 = Status(name='Status 1', code='STS1')
        self.test_status2 = Status(name='Status 2', code='STS2')
        self.test_status3 = Status(name='Status 3', code='STS3')
        self.test_status4 = Status(name='Status 4', code='STS4')
        self.test_status5 = Status(name='Status 5', code='STS5')
        DBSession.add_all([self.test_status1,
                           self.test_status2,
                           self.test_status3,
                           self.test_status4,
                           self.test_status5])

        # status lists
        self.test_proj_status_list = StatusList(
            name='Project Status List',
            statuses=[self.test_status1, self.test_status2, self.test_status3],
            target_entity_type='Project'
        )
        DBSession.add(self.test_proj_status_list)

        # create one project
        self.test_proj1 = Project(
            name='Test Project 1',
            code='TP1',
            repository=self.test_repo,
            status_list=self.test_proj_status_list,
            start=datetime.datetime(2013, 4, 4),
            end=datetime.datetime(2013, 5, 4)
        )
        DBSession.add(self.test_proj1)
        self.test_proj1.now = datetime.datetime(2013, 4, 4)

        # create task status list
        with DBSession.no_autoflush:
            self.test_task_status_list = StatusList.query\
                .filter_by(target_entity_type='Task').first()

        # create two tasks with the same resources
        self.test_task1 = Task(
            name='Task1',
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[
                self.test_user3, self.test_user4, self.test_user5
            ],
            schedule_model=0,
            schedule_timing=50,
            schedule_unit='h',
            status_list=self.test_task_status_list
        )
        DBSession.add(self.test_task1)

        self.test_task2 = Task(
            name='Task2',
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[
                self.test_user3, self.test_user4, self.test_user5
            ],
            depends=[self.test_task1],
            schedule_model=0,
            schedule_timing=60,
            schedule_unit='h',
            status_list=self.test_task_status_list
        )
        DBSession.add(self.test_task2)
        DBSession.commit()
コード例 #5
0
    def test_get_version_from_full_path_with_multiple_repositories(self):
        """testing if the get version from full path is working fine with
        multiple repositories and with same version names
        """
        repo1 = Repository(name="Test Repo 1", linux_path="/mnt/T/", windows_path="T:/", osx_path="/Volumes/T/")
        DBSession.add(repo1)

        repo2 = Repository(name="Test Repo 2", linux_path="/mnt/S/", windows_path="S:/", osx_path="/Volumes/S/")
        DBSession.add(repo2)

        task_ft = FilenameTemplate(
            name="Task Filename Template",
            target_entity_type="Task",
            path="$REPO{{project.repository.id}}/{{project.code}}/"
            "{%- for parent_task in parent_tasks -%}"
            "{{parent_task.nice_name}}/{%- endfor -%}",
            filename="{{task.nice_name}}_{{version.take_name}}" '_v{{"%03d"|format(version.version_number)}}',
        )
        DBSession.add(task_ft)

        structure1 = Structure(name="Commercial Project Structure", templates=[task_ft])
        DBSession.add(structure1)

        status1 = Status(name="Status 1", code="STS1")
        status2 = Status(name="Status 2", code="STS2")
        status3 = Status(name="Status 3", code="STS3")
        DBSession.add_all([status1, status2, status3])

        proj_status_list = StatusList(
            name="Project Statuses", target_entity_type="Project", statuses=[status1, status2, status3]
        )
        DBSession.add(proj_status_list)

        task_status_list = StatusList(
            name="Task Statuses", target_entity_type="Task", statuses=[status1, status2, status3]
        )
        DBSession.add(task_status_list)

        version_status_list = StatusList(
            name="Version Statuses", target_entity_type="Version", statuses=[status1, status2, status3]
        )
        DBSession.add(version_status_list)

        project1 = Project(
            name="Test Project 1", code="TP1", repositories=[repo1], structure=structure1, status_list=proj_status_list
        )
        DBSession.add(project1)

        project2 = Project(
            name="Test Project 2", code="TP2", repositories=[repo2], structure=structure1, status_list=proj_status_list
        )
        DBSession.add(project2)

        task1 = Task(name="Test Task 1", code="TT1", project=project1, status_list=task_status_list)
        DBSession.add(task1)

        task2 = Task(name="Test Task 1", code="TT1", project=project2, status_list=task_status_list)
        DBSession.add(task2)

        DBSession.commit()

        # now create versions
        version1 = Version(task=task1, status_list=version_status_list)
        DBSession.add(version1)
        DBSession.commit()
        version1.update_paths()

        version2 = Version(task=task2, status_list=version_status_list)
        DBSession.add(version2)
        DBSession.commit()
        version2.update_paths()

        DBSession.commit()
        logger.debug("version1.full_path : %s" % version1.full_path)
        logger.debug("version2.full_path : %s" % version2.full_path)

        # now try to get the versions with an EnvironmentBase instance
        env = EnvironmentBase()

        # version1
        version1_found = env.get_version_from_full_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version1_found, version1)

        # version2
        version2_found = env.get_version_from_full_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version2_found, version2)

        # version1 in windows
        version1_found = env.get_version_from_full_path("T:/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version1_found, version1)

        # version2 in windows
        version2_found = env.get_version_from_full_path("S:/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version2_found, version2)

        # version1 in linux
        version1_found = env.get_version_from_full_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version1_found, version1)

        # version2 in linux
        version2_found = env.get_version_from_full_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version2_found, version2)

        # version1 in osx
        version1_found = env.get_version_from_full_path("/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version1_found, version1)

        # version2 in osx
        version2_found = env.get_version_from_full_path("/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(version2_found, version2)
コード例 #6
0
    def test_trim_repo_path_with_multiple_repositories(self):
        """testing if the trim_repo_path is working fine with multiple
        repositories and with same version names
        """
        repo0 = Repository(
            name="Test Repo 0",
            linux_path="/mnt/T/with_a_very_long_path_which_will_cause_errors/",
            windows_path="T:/with_a_very_long_path_which_will_cause_errors/",
            osx_path="/Volumes/T/" "with_a_very_long_path_which_will_cause_errors/",
        )
        DBSession.add(repo0)

        repo1 = Repository(name="Test Repo 1", linux_path="/mnt/T/", windows_path="T:/", osx_path="/Volumes/T/")
        DBSession.add(repo1)

        repo2 = Repository(name="Test Repo 2", linux_path="/mnt/S/", windows_path="S:/", osx_path="/Volumes/S/")
        DBSession.add(repo2)

        task_ft = FilenameTemplate(
            name="Task Filename Template",
            target_entity_type="Task",
            path="{{project.code}}/{%- for parent_task in parent_tasks -%}" "{{parent_task.nice_name}}/{%- endfor -%}",
            filename="{{task.nice_name}}_{{version.take_name}}" '_v{{"%03d"|format(version.version_number)}}',
        )
        DBSession.add(task_ft)

        structure1 = Structure(name="Commercial Project Structure", templates=[task_ft])
        DBSession.add(structure1)

        status1 = Status(name="Status 1", code="STS1")
        status2 = Status(name="Status 2", code="STS2")
        status3 = Status(name="Status 3", code="STS3")
        DBSession.add_all([status1, status2, status3])

        proj_status_list = StatusList(
            name="Project Statuses", target_entity_type="Project", statuses=[status1, status2, status3]
        )
        DBSession.add(proj_status_list)

        task_status_list = StatusList(
            name="Task Statuses", target_entity_type="Task", statuses=[status1, status2, status3]
        )
        DBSession.add(task_status_list)

        version_status_list = StatusList(
            name="Version Statuses", target_entity_type="Version", statuses=[status1, status2, status3]
        )
        DBSession.add(version_status_list)

        project1 = Project(
            name="Test Project 1", code="TP1", repositories=[repo1], structure=structure1, status_list=proj_status_list
        )
        DBSession.add(project1)

        project2 = Project(
            name="Test Project 2", code="TP2", repositories=[repo2], structure=structure1, status_list=proj_status_list
        )
        DBSession.add(project2)

        task1 = Task(name="Test Task 1", code="TT1", project=project1, status_list=task_status_list)
        DBSession.add(task1)

        task2 = Task(name="Test Task 1", code="TT1", project=project2, status_list=task_status_list)
        DBSession.add(task2)

        DBSession.commit()

        # now create versions
        version1 = Version(task=task1, status_list=version_status_list)
        DBSession.add(version1)
        DBSession.commit()
        version1.update_paths()

        version2 = Version(task=task1, status_list=version_status_list)
        DBSession.add(version2)
        DBSession.commit()
        version2.update_paths()

        version3 = Version(task=task2, status_list=version_status_list)
        DBSession.add(version3)
        DBSession.commit()
        version3.update_paths()

        version4 = Version(task=task2, status_list=version_status_list)
        DBSession.add(version4)
        DBSession.commit()
        version4.update_paths()

        DBSession.commit()
        logger.debug("version1.full_path : %s" % version1.full_path)
        logger.debug("version2.full_path : %s" % version2.full_path)
        logger.debug("version3.full_path : %s" % version2.full_path)
        logger.debug("version4.full_path : %s" % version2.full_path)

        # now try to get the versions with an EnvironmentBase instance
        env = EnvironmentBase()

        expected_value1 = "TP1/Test_Task_1/Test_Task_1_Main_v001"
        expected_value2 = "TP2/Test_Task_1/Test_Task_1_Main_v001"

        # version1 native
        trimmed_path = env.trim_repo_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value1)

        # version2 native
        trimmed_path = env.trim_repo_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value2)

        # version1 windows
        trimmed_path = env.trim_repo_path("T:/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value1)

        # version2 windows
        trimmed_path = env.trim_repo_path("S:/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value2)

        # version1 linux
        trimmed_path = env.trim_repo_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value1)

        # version2 linux
        trimmed_path = env.trim_repo_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value2)

        # version1 osx
        trimmed_path = env.trim_repo_path("/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value1)

        # version2 osx
        trimmed_path = env.trim_repo_path("/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001")
        self.assertEqual(trimmed_path, expected_value2)
コード例 #7
0
    def setUp(self):
        """set up the test
        """
        db.setup()
        db.init()

        # get statuses
        self.status_new = Status.query.filter_by(code="NEW").first()
        self.status_wfd = Status.query.filter_by(code="WFD").first()
        self.status_rts = Status.query.filter_by(code="RTS").first()
        self.status_wip = Status.query.filter_by(code="WIP").first()
        self.status_prev = Status.query.filter_by(code="PREV").first()
        self.status_hrev = Status.query.filter_by(code="HREV").first()
        self.status_drev = Status.query.filter_by(code="DREV").first()
        self.status_oh = Status.query.filter_by(code="OH").first()
        self.status_stop = Status.query.filter_by(code="STOP").first()
        self.status_cmpl = Status.query.filter_by(code="CMPL").first()

        self.test_user1 = User(
            name='Test User 1',
            login='******',
            email='*****@*****.**',
            password='******'
        )

        self.test_user2 = User(
            name='Test User 2',
            login='******',
            email='*****@*****.**',
            password='******'
        )

        self.test_user3 = User(
            name='Test User 1',
            login='******',
            email='*****@*****.**',
            password='******'
        )

        self.test_repo = Repository(
            name='Test Repository'
        )

        self.test_structure = Structure(
            name='test structure'
        )

        # project status list
        self.test_project_status_list = StatusList(
            name='Project Statuses',
            target_entity_type='Project',
            statuses=[
                self.status_new,
                self.status_wip,
                self.status_oh,
                self.status_stop,
                self.status_cmpl
            ]
        )
        self.test_project1 = Project(
            name='Test Project 1',
            code='TP1',
            lead=self.test_user1,
            repository=self.test_repo,
            structure=self.test_structure,
            status_list=self.test_project_status_list
        )

        # create three Tasks
        self.test_task1 = Task(
            name='Test Task 1',
            project=self.test_project1
        )

        self.test_task2 = Task(
            name='Test Task 2',
            project=self.test_project1
        )

        self.test_task3 = Task(
            name='Test Task 3',
            project=self.test_project1
        )

        # add everything to db
        DBSession.add_all([
            self.test_project1, self.test_project_status_list, self.test_repo,
            self.test_structure, self.test_task1, self.test_task2,
            self.test_task3, self.test_user1, self.test_user2
        ])
        DBSession.commit()

        self.kwargs = {
            'task': self.test_task1,
            'depends_to': self.test_task2,
            'dependency_target': 'onend',
            'gap_timing': 0,
            'gap_unit': 'h',
            'gap_model': 'length'
        }
コード例 #8
0
    def setUp(self):
        """set up the test
        """
        db.setup()
        db.init()

        # get statuses
        self.status_new = Status.query.filter_by(code="NEW").first()
        self.status_wfd = Status.query.filter_by(code="WFD").first()
        self.status_rts = Status.query.filter_by(code="RTS").first()
        self.status_wip = Status.query.filter_by(code="WIP").first()
        self.status_prev = Status.query.filter_by(code="PREV").first()
        self.status_hrev = Status.query.filter_by(code="HREV").first()
        self.status_drev = Status.query.filter_by(code="DREV").first()
        self.status_oh = Status.query.filter_by(code="OH").first()
        self.status_stop = Status.query.filter_by(code="STOP").first()
        self.status_cmpl = Status.query.filter_by(code="CMPL").first()

        self.test_user1 = User(name='Test User 1',
                               login='******',
                               email='*****@*****.**',
                               password='******')

        self.test_user2 = User(name='Test User 2',
                               login='******',
                               email='*****@*****.**',
                               password='******')

        self.test_user3 = User(name='Test User 1',
                               login='******',
                               email='*****@*****.**',
                               password='******')

        self.test_repo = Repository(name='Test Repository')

        self.test_structure = Structure(name='test structure')

        # project status list
        self.test_project_status_list = StatusList(
            name='Project Statuses',
            target_entity_type='Project',
            statuses=[
                self.status_new, self.status_wip, self.status_oh,
                self.status_stop, self.status_cmpl
            ])
        self.test_project1 = Project(name='Test Project 1',
                                     code='TP1',
                                     repository=self.test_repo,
                                     structure=self.test_structure,
                                     status_list=self.test_project_status_list)

        # create three Tasks
        self.test_task1 = Task(name='Test Task 1', project=self.test_project1)

        self.test_task2 = Task(name='Test Task 2', project=self.test_project1)

        self.test_task3 = Task(name='Test Task 3', project=self.test_project1)

        # add everything to db
        DBSession.add_all([
            self.test_project1, self.test_project_status_list, self.test_repo,
            self.test_structure, self.test_task1, self.test_task2,
            self.test_task3, self.test_user1, self.test_user2
        ])
        DBSession.commit()

        self.kwargs = {
            'task': self.test_task1,
            'depends_to': self.test_task2,
            'dependency_target': 'onend',
            'gap_timing': 0,
            'gap_unit': 'h',
            'gap_model': 'length'
        }
コード例 #9
0
    def test_get_version_from_full_path_with_multiple_repositories(self):
        """testing if the get version from full path is working fine with
        multiple repositories and with same version names
        """
        repo1 = Repository(name='Test Repo 1',
                           linux_path='/mnt/T/',
                           windows_path='T:/',
                           osx_path='/Volumes/T/')
        DBSession.add(repo1)

        repo2 = Repository(name='Test Repo 2',
                           linux_path='/mnt/S/',
                           windows_path='S:/',
                           osx_path='/Volumes/S/')
        DBSession.add(repo2)

        task_ft = FilenameTemplate(
            name='Task Filename Template',
            target_entity_type='Task',
            path='$REPO{{project.repository.code}}/{{project.code}}/'
            '{%- for parent_task in parent_tasks -%}'
            '{{parent_task.nice_name}}/{%- endfor -%}',
            filename='{{task.nice_name}}_{{version.take_name}}'
            '_v{{"%03d"|format(version.version_number)}}',
        )
        DBSession.add(task_ft)

        structure1 = Structure(name='Commercial Project Structure',
                               templates=[task_ft])
        DBSession.add(structure1)

        status1 = Status(name='Status 1', code='STS1')
        status2 = Status(name='Status 2', code='STS2')
        status3 = Status(name='Status 3', code='STS3')
        DBSession.add_all([status1, status2, status3])

        proj_status_list = \
            StatusList.query.filter_by(target_entity_type='Project').first()

        task_status_list = \
            StatusList.query.filter_by(target_entity_type='Task').first()

        version_status_list = StatusList(name='Version Statuses',
                                         target_entity_type='Version',
                                         statuses=[status1, status2, status3])
        DBSession.add(version_status_list)

        project1 = Project(name='Test Project 1',
                           code='TP1',
                           repositories=[repo1],
                           structure=structure1,
                           status_list=proj_status_list)
        DBSession.add(project1)

        project2 = Project(name='Test Project 2',
                           code='TP2',
                           repositories=[repo2],
                           structure=structure1,
                           status_list=proj_status_list)
        DBSession.add(project2)

        task1 = Task(name='Test Task 1',
                     code='TT1',
                     project=project1,
                     status_list=task_status_list)
        DBSession.add(task1)

        task2 = Task(name='Test Task 1',
                     code='TT1',
                     project=project2,
                     status_list=task_status_list)
        DBSession.add(task2)

        DBSession.commit()

        # now create versions
        version1 = Version(task=task1, status_list=version_status_list)
        DBSession.add(version1)
        DBSession.commit()
        version1.update_paths()

        version2 = Version(task=task2, status_list=version_status_list)
        DBSession.add(version2)
        DBSession.commit()
        version2.update_paths()

        DBSession.commit()
        logger.debug('version1.full_path : %s' % version1.full_path)
        logger.debug('version2.full_path : %s' % version2.full_path)

        # now try to get the versions with an EnvironmentBase instance
        env = EnvironmentBase()

        # version1
        version1_found = env.get_version_from_full_path(
            '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version1_found, version1)

        # version2
        version2_found = env.get_version_from_full_path(
            '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version2_found, version2)

        # version1 in windows
        version1_found = env.get_version_from_full_path(
            'T:/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version1_found, version1)

        # version2 in windows
        version2_found = env.get_version_from_full_path(
            'S:/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version2_found, version2)

        # version1 in linux
        version1_found = env.get_version_from_full_path(
            '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version1_found, version1)

        # version2 in linux
        version2_found = env.get_version_from_full_path(
            '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version2_found, version2)

        # version1 in osx
        version1_found = env.get_version_from_full_path(
            '/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version1_found, version1)

        # version2 in osx
        version2_found = env.get_version_from_full_path(
            '/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(version2_found, version2)
コード例 #10
0
    def test_trim_repo_path_with_multiple_repositories(self):
        """testing if the trim_repo_path is working fine with multiple
        repositories and with same version names
        """
        repo0 = Repository(
            name='Test Repo 0',
            linux_path='/mnt/T/with_a_very_long_path_which_will_cause_errors/',
            windows_path='T:/with_a_very_long_path_which_will_cause_errors/',
            osx_path='/Volumes/T/'
            'with_a_very_long_path_which_will_cause_errors/')
        DBSession.add(repo0)

        repo1 = Repository(name='Test Repo 1',
                           linux_path='/mnt/T/',
                           windows_path='T:/',
                           osx_path='/Volumes/T/')
        DBSession.add(repo1)

        repo2 = Repository(name='Test Repo 2',
                           linux_path='/mnt/S/',
                           windows_path='S:/',
                           osx_path='/Volumes/S/')
        DBSession.add(repo2)

        task_ft = FilenameTemplate(
            name='Task Filename Template',
            target_entity_type='Task',
            path='{{project.code}}/{%- for parent_task in parent_tasks -%}'
            '{{parent_task.nice_name}}/{%- endfor -%}',
            filename='{{task.nice_name}}_{{version.take_name}}'
            '_v{{"%03d"|format(version.version_number)}}',
        )
        DBSession.add(task_ft)

        structure1 = Structure(name='Commercial Project Structure',
                               templates=[task_ft])
        DBSession.add(structure1)

        status1 = Status(name='Status 1', code='STS1')
        status2 = Status(name='Status 2', code='STS2')
        status3 = Status(name='Status 3', code='STS3')
        DBSession.add_all([status1, status2, status3])

        proj_status_list = \
            StatusList.query.filter_by(target_entity_type='Project').first()

        task_status_list = \
            StatusList.query.filter_by(target_entity_type='Task').first()
        DBSession.add(task_status_list)

        project1 = Project(name='Test Project 1',
                           code='TP1',
                           repositories=[repo1],
                           structure=structure1,
                           status_list=proj_status_list)
        DBSession.add(project1)

        project2 = Project(name='Test Project 2',
                           code='TP2',
                           repositories=[repo2],
                           structure=structure1,
                           status_list=proj_status_list)
        DBSession.add(project2)

        task1 = Task(name='Test Task 1',
                     code='TT1',
                     project=project1,
                     status_list=task_status_list)
        DBSession.add(task1)

        task2 = Task(name='Test Task 1',
                     code='TT1',
                     project=project2,
                     status_list=task_status_list)
        DBSession.add(task2)

        DBSession.commit()

        # now create versions
        version1 = Version(task=task1, status_list=version_status_list)
        DBSession.add(version1)
        DBSession.commit()
        version1.update_paths()

        version2 = Version(task=task1)
        DBSession.add(version2)
        DBSession.commit()
        version2.update_paths()

        version3 = Version(task=task2)
        DBSession.add(version3)
        DBSession.commit()
        version3.update_paths()

        version4 = Version(task=task2)
        DBSession.add(version4)
        DBSession.commit()
        version4.update_paths()

        DBSession.commit()
        logger.debug('version1.full_path : %s' % version1.full_path)
        logger.debug('version2.full_path : %s' % version2.full_path)
        logger.debug('version3.full_path : %s' % version2.full_path)
        logger.debug('version4.full_path : %s' % version2.full_path)

        # now try to get the versions with an EnvironmentBase instance
        env = EnvironmentBase()

        expected_value1 = 'TP1/Test_Task_1/Test_Task_1_Main_v001'
        expected_value2 = 'TP2/Test_Task_1/Test_Task_1_Main_v001'

        # version1 native
        trimmed_path = env.trim_repo_path(
            '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value1)

        # version2 native
        trimmed_path = env.trim_repo_path(
            '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value2)

        # version1 windows
        trimmed_path = env.trim_repo_path(
            'T:/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value1)

        # version2 windows
        trimmed_path = env.trim_repo_path(
            'S:/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value2)

        # version1 linux
        trimmed_path = env.trim_repo_path(
            '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value1)

        # version2 linux
        trimmed_path = env.trim_repo_path(
            '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value2)

        # version1 osx
        trimmed_path = env.trim_repo_path(
            '/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value1)

        # version2 osx
        trimmed_path = env.trim_repo_path(
            '/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001')
        self.assertEqual(trimmed_path, expected_value2)
コード例 #11
0
    def setUp(self):
        """set up the test
        """
        # we need a database
        db.setup(self.config)
        db.init()

        # replace datetime now function

        # create departments
        self.test_dep1 = Department(name='Dep1')
        self.test_dep2 = Department(name='Dep2')

        # create resources
        self.test_user1 = User(
            login='******',
            name='User1',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep1]
        )
        DBSession.add(self.test_user1)

        self.test_user2 = User(
            login='******',
            name='User2',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep1]
        )
        DBSession.add(self.test_user2)

        self.test_user3 = User(
            login='******',
            name='User3',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep2]
        )
        DBSession.add(self.test_user3)

        self.test_user4 = User(
            login='******',
            name='User4',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep2]
        )
        DBSession.add(self.test_user4)

        # user with two departments
        self.test_user5 = User(
            login='******',
            name='User5',
            email='*****@*****.**',
            password='******',
            departments=[self.test_dep1, self.test_dep2]
        )
        DBSession.add(self.test_user5)

        # user with no departments
        self.test_user6 = User(
            login='******',
            name='User6',
            email='*****@*****.**',
            password='******'
        )
        DBSession.add(self.test_user6)

        # repository
        self.test_repo = Repository(
            name='Test Repository',
            linux_path='/mnt/T/',
            windows_path='T:/',
            osx_path='/Volumes/T/'
        )
        DBSession.add(self.test_repo)

        # statuses
        self.test_status1 = Status(name='Status 1', code='STS1')
        self.test_status2 = Status(name='Status 2', code='STS2')
        self.test_status3 = Status(name='Status 3', code='STS3')
        self.test_status4 = Status(name='Status 4', code='STS4')
        self.test_status5 = Status(name='Status 5', code='STS5')
        DBSession.add_all([self.test_status1,
                           self.test_status2,
                           self.test_status3,
                           self.test_status4,
                           self.test_status5])

        # status lists
        self.test_proj_status_list = StatusList(
            name='Project Status List',
            statuses=[self.test_status1, self.test_status2, self.test_status3],
            target_entity_type='Project'
        )
        DBSession.add(self.test_proj_status_list)

        # create one project
        self.test_proj1 = Project(
            name='Test Project 1',
            code='TP1',
            repository=self.test_repo,
            status_list=self.test_proj_status_list,
            start=datetime.datetime(2013, 4, 4),
            end=datetime.datetime(2013, 5, 4)
        )
        DBSession.add(self.test_proj1)
        self.test_proj1.now = datetime.datetime(2013, 4, 4)

        # create task status list
        with DBSession.no_autoflush:
            self.test_task_status_list = StatusList.query\
                .filter_by(target_entity_type='Task').first()

        # create two tasks with the same resources
        self.test_task1 = Task(
            name='Task1',
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[
                self.test_user3, self.test_user4, self.test_user5
            ],
            schedule_model=0,
            schedule_timing=50,
            schedule_unit='h',
            status_list=self.test_task_status_list
        )
        DBSession.add(self.test_task1)

        self.test_task2 = Task(
            name='Task2',
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[
                self.test_user3, self.test_user4, self.test_user5
            ],
            depends=[self.test_task1],
            schedule_model=0,
            schedule_timing=60,
            schedule_unit='h',
            status_list=self.test_task_status_list
        )
        DBSession.add(self.test_task2)
        DBSession.commit()
コード例 #12
0
    def setUp(self):
        """set up the test
        """
        # we need a database
        db.setup(self.config)
        db.init()

        # replace datetime now function

        # create departments
        self.test_dep1 = Department(name="Dep1")
        self.test_dep2 = Department(name="Dep2")

        # create resources
        self.test_user1 = User(
            login="******", name="User1", email="*****@*****.**", password="******", departments=[self.test_dep1]
        )
        DBSession.add(self.test_user1)

        self.test_user2 = User(
            login="******", name="User2", email="*****@*****.**", password="******", departments=[self.test_dep1]
        )
        DBSession.add(self.test_user2)

        self.test_user3 = User(
            login="******", name="User3", email="*****@*****.**", password="******", departments=[self.test_dep2]
        )
        DBSession.add(self.test_user3)

        self.test_user4 = User(
            login="******", name="User4", email="*****@*****.**", password="******", departments=[self.test_dep2]
        )
        DBSession.add(self.test_user4)

        # user with two departments
        self.test_user5 = User(
            login="******",
            name="User5",
            email="*****@*****.**",
            password="******",
            departments=[self.test_dep1, self.test_dep2],
        )
        DBSession.add(self.test_user5)

        # user with no departments
        self.test_user6 = User(login="******", name="User6", email="*****@*****.**", password="******")
        DBSession.add(self.test_user6)

        # repository
        self.test_repo = Repository(
            name="Test Repository", linux_path="/mnt/T/", windows_path="T:/", osx_path="/Volumes/T/"
        )
        DBSession.add(self.test_repo)

        # statuses
        self.test_status1 = Status(name="Status 1", code="STS1")
        self.test_status2 = Status(name="Status 2", code="STS2")
        self.test_status3 = Status(name="Status 3", code="STS3")
        self.test_status4 = Status(name="Status 4", code="STS4")
        self.test_status5 = Status(name="Status 5", code="STS5")
        DBSession.add_all(
            [self.test_status1, self.test_status2, self.test_status3, self.test_status4, self.test_status5]
        )

        # status lists
        self.test_proj_status_list = StatusList(
            name="Project Status List",
            statuses=[self.test_status1, self.test_status2, self.test_status3],
            target_entity_type="Project",
        )
        DBSession.add(self.test_proj_status_list)

        # create one project
        self.test_proj1 = Project(
            name="Test Project 1",
            code="TP1",
            repository=self.test_repo,
            status_list=self.test_proj_status_list,
            start=datetime.datetime(2013, 4, 4),
            end=datetime.datetime(2013, 5, 4),
        )
        DBSession.add(self.test_proj1)
        self.test_proj1.now = datetime.datetime(2013, 4, 4)

        # create task status list
        with DBSession.no_autoflush:
            self.test_task_status_list = StatusList.query.filter_by(target_entity_type="Task").first()

        # create two tasks with the same resources
        self.test_task1 = Task(
            name="Task1",
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[self.test_user3, self.test_user4, self.test_user5],
            schedule_model=0,
            schedule_timing=50,
            schedule_unit="h",
            status_list=self.test_task_status_list,
        )
        DBSession.add(self.test_task1)

        self.test_task2 = Task(
            name="Task2",
            project=self.test_proj1,
            resources=[self.test_user1, self.test_user2],
            alternative_resources=[self.test_user3, self.test_user4, self.test_user5],
            depends=[self.test_task1],
            schedule_model=0,
            schedule_timing=60,
            schedule_unit="h",
            status_list=self.test_task_status_list,
        )
        DBSession.add(self.test_task2)
        DBSession.commit()
コード例 #13
0
ファイル: ticket.py プロジェクト: attila3d/stalker-pyramid
def update_ticket(request):
    """runs when updating a ticket
    """
    logged_in_user = get_logged_in_user(request)

    ticket_id = request.matchdict.get('id', -1)
    ticket = Ticket.query.filter_by(id=ticket_id).first()

    #**************************************************************************
    # collect data
    comment = request.params.get('comment')
    comment_as_text = request.params.get('comment_as_text')
    action = request.params.get('action')

    logger.debug('updating ticket')
    if not ticket:
        transaction.abort()
        return Response('No ticket with id : %s' % ticket_id, 500)

    utc_now = local_to_utc(datetime.datetime.now())
    ticket_log = None

    if not action.startswith('leave_as'):
        if logged_in_user == ticket.owner or \
           logged_in_user == ticket.created_by:
            if action.startswith('resolve_as'):
                resolution = action.split(':')[1]
                ticket_log = ticket.resolve(logged_in_user, resolution)
            elif action.startswith('set_owner'):
                user_id = int(action.split(':')[1])
                assign_to = User.query.get(user_id)
                ticket_log = ticket.reassign(logged_in_user, assign_to)
            elif action.startswith('delete_resolution'):
                ticket_log = ticket.reopen(logged_in_user)
            ticket.date_updated = utc_now
            if ticket_log:
                ticket_log.date_created = utc_now
                ticket_log.date_updated = utc_now
        else:
            transaction.abort()
            return Response(
                'Error: You are not the owner nor the creator of this ticket'
                '\n\nSo, you do not have permission to update the ticket', 500
            )

    # mail
    recipients = [
        logged_in_user.email,
        ticket.created_by.email,
        ticket.owner.email
    ]

    # mail the comment to anybody related to the ticket
    if comment:
        # convert images to Links
        attachments = []
        comment, links = replace_img_data_with_links(comment)
        if links:
            # update created_by attributes of links
            for link in links:
                link.created_by = logged_in_user

                # manage attachments
                link_full_path = convert_file_link_to_full_path(link.full_path)
                link_data = open(link_full_path, "rb").read()

                link_extension = os.path.splitext(link.filename)[1].lower()
                mime_type = ''
                if link_extension in ['.jpeg', '.jpg']:
                    mime_type = 'image/jpg'
                elif link_extension in ['.png']:
                    mime_type = 'image/png'

                attachment = Attachment(
                    link.filename,
                    mime_type,
                    link_data
                )
                attachments.append(attachment)
            DBSession.add_all(links)

        note = Note(
            content=comment,
            created_by=logged_in_user,
            date_created=utc_now
        )
        ticket.comments.append(note)
        DBSession.add(note)

        # send email to the owner about the new comment
        mailer = get_mailer(request)

        # also inform ticket commenter
        for t_comment in ticket.comments:
            recipients.append(t_comment.created_by.email)

        message_body_text = "%(who)s has added a the following comment to " \
                            "%(ticket)s:\n\n%(comment)s"

        message_body_html = "<div>%(who)s has added a the following comment " \
                            "to %(ticket)s:<br><br>%(comment)s</div>"

        message_body_text = message_body_text % {
            'who': logged_in_user.name,
            'ticket': "Ticket #%s" % ticket.number,
            'comment': comment_as_text
        }

        message_body_html = message_body_html % {
            'who': '<a href="%(link)s">%(name)s</a>' % {
                'link': request.route_url('view_user', id=logged_in_user.id),
                'name': logged_in_user.name
            },
            'ticket': '<a href="%(link)s">%(name)s</a>' % {
                'link': request.route_url('view_ticket', id=ticket.id),
                'name': "Ticket #%(number)s - %(summary)s" % {
                    'number': ticket.number,
                    'summary': ticket.summary
                }
            },
            'comment': re.sub(
                r'/SPL/[a-z0-9]+/[a-z0-9]+/',
                'cid:',
                comment
            )
        }

        # make recipients unique
        recipients = list(set(recipients))
        message = Message(
            subject="Stalker Pyramid: New comment on Ticket #%s" %
                    ticket.number,
            sender=dummy_email_address,
            recipients=recipients,
            body=message_body_text,
            html=message_body_html,
            attachments=attachments
        )
        mailer.send(message)

    # mail about changes in ticket status
    if ticket_log:
        from stalker import TicketLog

        assert isinstance(ticket_log, TicketLog)
        mailer = get_mailer(request)

        # just inform anybody in the previously created recipients list

        message_body_text = \
            '%(user)s has changed the status of %(ticket)s\n\n' \
            'from "%(from)s" to "%(to)s"'

        message_body_html = \
            '<div>%(user)s has changed the status of ' \
            '%(ticket)s:<br><br>from %(from)s to %(to)s</div>'

        message_body_text = message_body_text % {
            'user': ticket_log.created_by.name,
            'ticket': "Ticket #%s" % ticket.number,
            'from': ticket_log.from_status.name,
            'to': ticket_log.to_status.name
        }

        message_body_html = message_body_html % {
            'user': '******' % {
                'name': ticket_log.created_by.name
            },
            'ticket': "<strong>Ticket #%(number)s - %(summary)s</strong>" % {
                'number': ticket.number,
                'summary': ticket.summary
            },
            'from': '<strong>%s</strong>' % ticket_log.from_status.name,
            'to': '<strong>%s</strong>' % ticket_log.to_status.name
        }

        message = Message(
            subject="Stalker Pyramid: Status Update on "
                    "Ticket #%(ticket_number)s - %(ticket_summary)s" % {
                        'ticket_number': ticket.number,
                        'ticket_summary': ticket.summary
                    },
            sender=dummy_email_address,
            recipients=recipients,
            body=message_body_text,
            html=message_body_html
        )
        mailer.send(message)

    logger.debug('successfully updated ticket')

    request.session.flash('Success: Successfully updated ticket')
    return Response('Successfully updated ticket')
コード例 #14
0
    def test_creating_a_time_log_for_a_leaf_task_will_set_its_parents_status_to_wip(self):
        """testing if the status of the parent task will turn to wip if time
        log is entered to a child task
        """
        # TODO: This is also testing some functionality from view.task, slit it
        # create two new task
        task0 = Task(
            name='Test Task 0',
            project=self.proj1,
            status_list=self.task_status_list
        )
        task1 = Task(
            name='Test Task 1',
            parent=task0,
            status_list=self.task_status_list
        )
        task2 = Task(
            name='Test Task 2',
            parent=task1,
            resources=[self.user1],
            status_list=self.task_status_list,
            status=self.status_rts
        )
        task3 = Task(
            name='Test Task 3',
            parent=task1,
            resources=[self.user1],
            status_list=self.task_status_list,
            status=self.status_rts
        )
        task4 = Task(
            name='Test Task 4',
            parent=task0,
            resources=[self.user1],
            status_list=self.task_status_list,
            status=self.status_rts
        )
        DBSession.add_all([task0, task1, task2, task3, task4])
        DBSession.commit()
        DBSession.flush()
        transaction.commit()

        self.assertEqual(task0.status, self.status_new)
        self.assertEqual(task1.status, self.status_new)
        self.assertEqual(task2.status, self.status_rts)
        self.assertEqual(task3.status, self.status_rts)
        self.assertEqual(task4.status, self.status_rts)

        # now add a time log for task3 through create_time_log view
        request = testing.DummyRequest()

        # patch get_logged_in_user
        admins = Group.query.filter(Group.name == 'admins').first()
        self.user1.groups.append(admins)
        m = mocker.Mocker()
        obj = m.replace("stalker_pyramid.views.auth.get_logged_in_user")
        obj(request)
        m.result(self.user1)
        m.count(1, 1000000000)
        m.replay()
        request.route_url = lambda x, id=1: 'view_user'

        request.params['task_id'] = task3.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 19 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 19 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)

        # now expect to have the status of task1 to be wip
        self.assertEqual(task3.status, self.status_wip)
        self.assertEqual(task2.status, self.status_rts)
        self.assertEqual(task1.status, self.status_wip)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)

        request.params['task_id'] = task2.id
        request.params['resource_id'] = self.user1.id
        request.params['start'] = "Fri, 18 Nov 2013 08:00:00 GMT"
        request.params['end'] = "Fri, 18 Nov 2013 17:00:00 GMT"
        response = time_log.create_time_log(request)
        self.assertEqual(response.status_int, 200)

        # now expect to have the status of task1 to be wip
        self.assertEqual(task3.status, self.status_wip)
        self.assertEqual(task2.status, self.status_wip)
        self.assertEqual(task1.status, self.status_wip)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)

        # now request a review and approve the task2 and task3 and expect the
        # task1 status is complete
        from stalker_pyramid.views.task import request_review, review_task
        #request = testing.DummyRequest()
        request.matchdict['id'] = task2.id
        request.params['send_email'] = 0
        request.route_url = lambda x, id: 'localhost:6453/tasks/23/view'
        request.route_path = lambda x, id: '/tasks/23/view'

        response = request_review(request)
        self.assertEqual(response.status_int, 200)

        #request = testing.DummyRequest()
        request.matchdict['id'] = task3.id
        request.params['send_email'] = 0
        response = request_review(request)
        print response.body
        self.assertEqual(response.status_int, 200)

        self.assertEqual(task3.status, self.status_prev)
        self.assertEqual(task2.status, self.status_prev)
        self.assertEqual(task1.status, self.status_wip)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)

        # approve the task2
        request.matchdict['id'] = task2.id
        request.params['review'] = 'Approve'
        response = review_task(request)
        self.assertEqual(response.status_int, 200)

        # and except task1 is still wip
        self.assertEqual(task3.status, self.status_prev)
        self.assertEqual(task2.status, self.status_cmpl)
        self.assertEqual(task1.status, self.status_wip)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)

        # approve the task3
        request.matchdict['id'] = task3.id
        request.params['review'] = 'Approve'
        response = review_task(request)
        self.assertEqual(response.status_int, 200)

        # now check the statuses
        self.assertEqual(task3.status, self.status_cmpl)
        self.assertEqual(task2.status, self.status_cmpl)
        self.assertEqual(task1.status, self.status_cmpl)
        self.assertEqual(task0.status, self.status_wip)
        self.assertEqual(task4.status, self.status_rts)