def test_logbook_save(self): # Create a generic logbook to save lb_id = uuidutils.generate_uuid() lb_name = 'lb-%s' % (lb_id) lb = logbook.LogBook(lb_name, lb_id) # Save the logbook and record its uuid and name b_api.logbook_save(lb) self.lb_names.append(lb_name) self.lb_ids.append(lb_id) # Check that the saved logbook exists in the backend actual = b_api.logbook_get(lb_id) self.assertIsNotNone(actual) # Check that the saved logbook has no flowdetails self.assertEquals(len(actual), 0) # Add a flowdetail to the logbook fd = b_api.flowdetail_get(self.fd_ids[0]) lb.add_flow_detail(fd) # Save the updated logbook b_api.logbook_save(lb) # Check that the updated logbook is still in the backend actual = b_api.logbook_get(lb_id) self.assertIsNotNone(actual) # Check that the added flowdetail was recorded self.assertEquals(len(actual), 1)
def test_logbook_add_flow_detail(self): # Get the logbook from the backend actual = b_api.logbook_get(self.lb_ids[0]) # Check that it has no flowdetails self.assertEquals(len(actual), 0) # Add a flowdetail to the logbook b_api.logbook_add_flow_detail(self.lb_ids[0], self.fd_ids[0]) # Get the logbook again actual = b_api.logbook_get(self.lb_ids[0]) # Check that the logbook has exactly one flowdetail self.assertEquals(len(actual), 1)
def test_logbook_get(self): # Get the logbook from the backend actual = b_api.logbook_get(self.lb_ids[0]) # Check that it is actually a logbook self.assertIsInstance(actual, logbook.LogBook) # Check that the name is correct self.assertEquals(actual.name, self.lb_names[0])
def test_logbook_remove_flowdetail(self): # Add a flowdetail to the first logbook b_api.logbook_add_flow_detail(self.lb_ids[0], self.fd_ids[0]) # Get the first logbook actual = b_api.logbook_get(self.lb_ids[0]) # Check that it has exactly one flowdetail self.assertEquals(len(actual), 1) # Remove the flowdetail from the logbook b_api.logbook_remove_flowdetail(self.lb_ids[0], self.fd_ids[0]) # Get the logbook again actual = b_api.logbook_get(self.lb_ids[0]) # Check that the logbook now has no flowdetails self.assertEquals(len(actual), 0)
def test_logbook_delete(self): # Get the logbook to delete id = self.lb_ids.pop() lb = b_api.logbook_get(id) # Delete the logbook from the backend b_api.logbook_delete(lb) self.lb_names.pop() # Check that the deleted logbook is no longer present self.assertRaises(exception.NotFound, b_api.logbook_get, id)
def test_logbook_create(self): # Create a logbook and record its uuid and name lb_id = uuidutils.generate_uuid() lb_name = 'lb-%s' % (lb_id) b_api.logbook_create(lb_name, lb_id) self.lb_names.append(lb_name) self.lb_ids.append(lb_id) # Check that the created logbook exists in the backend actual = b_api.logbook_get(lb_id) self.assertIsNotNone(actual)