def test_taskdetail_update(self):
        # Get the first taskdetail and check for default attributes
        actual = b_api.taskdetail_get(self.td_ids[0])

        self.assertIsNone(actual.state)
        self.assertIsNone(actual.results)
        self.assertIsNone(actual.exception)
        self.assertIsNone(actual.stacktrace)
        self.assertIsNone(actual.meta)

        # Prepare attributes for updating
        values = dict(state='SUCCESS', exception='ERROR',
                      stacktrace='STACKTRACE', meta='META')

        # Update attributes
        b_api.taskdetail_update(self.td_ids[0], values)

        # Get the updated taskdetila and check for updated attributes
        actual = b_api.taskdetail_get(self.td_ids[0])

        self.assertEquals(actual.state, 'SUCCESS')
        self.assertIsNone(actual.results)
        self.assertEquals(actual.exception, 'ERROR')
        self.assertEquals(actual.stacktrace, 'STACKTRACE')
        self.assertEquals(actual.meta, 'META')
    def test_flowdetail_save(self):
        # Create a generic flowdetail to save
        fd_id = uuidutils.generate_uuid()
        fd_name = 'fd-%s' % (fd_id)
        wf = self.wfs[0]
        fd = flowdetail.FlowDetail(fd_name, wf, fd_id)

        # Save the generic flowdetail to the backend and record its uuid/name
        b_api.flowdetail_save(fd)
        self.fd_names.append(fd_name)
        self.fd_ids.append(fd_id)

        # Check that the saved flowdetail is in the backend
        actual = b_api.flowdetail_get(fd_id)

        self.assertIsNotNone(actual)
        # Check that the saved flowdetail has no taskdetails
        self.assertEquals(len(actual), 0)

        # Add a generic taskdetail to the flowdetail
        td = b_api.taskdetail_get(self.td_ids[0])
        fd.add_task_detail(td)

        # Save the updated flowdetail
        b_api.flowdetail_save(fd)

        # Check that the saved flowdetail is still there
        actual = b_api.flowdetail_get(fd_id)

        self.assertIsNotNone(actual)
        # Check that the addition of a taskdetail was recorded
        self.assertEquals(len(actual), 1)
    def test_taskdetail_get(self):
        # Get the first taskdetail
        actual = b_api.taskdetail_get(self.td_ids[0])

        # Check that it is actually a taskdetail
        self.assertIsInstance(actual, taskdetail.TaskDetail)
        # Check that its name is what we expect
        self.assertEquals(actual.name, self.td_names[0])
    def test_taskdetail_delete(self):
        # Get the taskdetail to delete
        id = self.td_ids.pop()
        td = b_api.taskdetail_get(id)
        # Delete the desired taskdetail
        b_api.taskdetail_delete(td)
        self.td_names.pop()

        # Check that the deleted taskdetail is no longer there
        self.assertRaises(exception.NotFound, b_api.taskdetail_get,
                          id)
    def test_taskdetail_save(self):
        # Create a generic taskdetail to save
        td_id = uuidutils.generate_uuid()
        td_name = 'td-%s' % (td_id)
        tsk = self.tsks[0]
        td = taskdetail.TaskDetail(td_name, tsk, td_id)

        # Save the generic taskdetail to the backend and record uuid/name
        b_api.taskdetail_save(td)
        self.td_names.append(td_name)
        self.td_ids.append(td_id)

        # Get the created taskdetail and check for default attributes
        actual = b_api.taskdetail_get(td_id)

        self.assertIsNotNone(actual)
        self.assertIsNone(actual.state)
        self.assertIsNone(actual.results)
        self.assertIsNone(actual.exception)
        self.assertIsNone(actual.stacktrace)
        self.assertIsNone(actual.meta)

        # Change the generic taskdetail's attributes
        td.state = 'SUCCESS'
        td.exception = 'ERROR'
        td.stacktrace = 'STACKTRACE'
        td.meta = 'META'

        # Save the changed taskdetail
        b_api.taskdetail_save(td)

        # Get the updated taskdetail and check for updated attributes
        actual = b_api.taskdetail_get(td_id)

        self.assertEquals(actual.state, 'SUCCESS')
        self.assertIsNone(actual.results)
        self.assertEquals(actual.exception, 'ERROR')
        self.assertEquals(actual.stacktrace, 'STACKTRACE')
        self.assertEquals(actual.meta, 'META')
    def test_taskdetail_create(self):
        # Create a taskdetail and record its uuid and name
        td_id = uuidutils.generate_uuid()
        td_name = 'td-%s' % (td_id)

        b_api.taskdetail_create(td_name, self.tsks[0], td_id)
        self.td_names.append(td_name)
        self.td_ids.append(td_id)

        # Check that the taskdetail is there
        actual = b_api.taskdetail_get(td_id)

        self.assertIsNotNone(actual)