def test_read_tracker_field_by_display_name(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) # Positive tests --------------------------------------------------------------------------- tracker_field1 = \ TrackerFieldManagementInterface.read_tracker_field_by_display_name("Test 1") self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], True) self.assertIsNotNone(tracker_field1["revision_id"]) self.assertIsNone( TrackerFieldManagementInterface.read_tracker_field_by_display_name( tracker_field1["display_name"], tracker_field1["revision_id"] - 1)) # Negative tests --------------------------------------------------------------------------- self.assertIsNone(TrackerFieldManagementInterface.read_tracker_field_by_display_name("")) self.assertIsNone( TrackerFieldManagementInterface.read_tracker_field_by_display_name("Test XYZ"))
def test_read_tracker_field_by_name(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) # Positive tests --------------------------------------------------------------------------- tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_name( "test1") self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], True) self.assertIsNotNone(tracker_field1["revision_id"]) self.assertIsNone( TrackerFieldManagementInterface.read_tracker_field_by_name( tracker_field1["name"], tracker_field1["revision_id"] - 1)) # Negative tests --------------------------------------------------------------------------- self.assertIsNone( TrackerFieldManagementInterface.read_tracker_field_by_name("")) self.assertIsNone( TrackerFieldManagementInterface.read_tracker_field_by_name( "test999"))
def test_update_tracker_field_invalid_tracker_field_id(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Positive tests --------------------------------------------------------------------------- # Try to update a tracker field with a reference to a non-existing tracker field ID self.assertFalse(TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, 999, tracker_field2["name"], tracker_field2["display_name"], tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"]))
def test_update_tracker_field_invalid_tracker_field_id(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Positive tests --------------------------------------------------------------------------- # Try to update a tracker field with a reference to a non-existing tracker field ID self.assertFalse( TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, 999, tracker_field2["name"], tracker_field2["display_name"], tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"]))
def test_deactivate_activate_tracker_field(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertIsNotNone(tracker_field2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Positive tests --------------------------------------------------------------------------- # Deactivate tracker field self.assertTrue( TrackerFieldManagementInterface.deactivate_tracker_field( self.__admin_user_id, tracker_field_id2)) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], False) self.assertIsNotNone(tracker_field2["revision_id"]) # Activate tracker self.assertTrue( TrackerFieldManagementInterface.activate_tracker_field( self.__admin_user_id, tracker_field_id2)) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"])
def test_deactivate_activate_tracker_field(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertIsNotNone(tracker_field2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Positive tests --------------------------------------------------------------------------- # Deactivate tracker field self.assertTrue(TrackerFieldManagementInterface.deactivate_tracker_field( self.__admin_user_id, tracker_field_id2)) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], False) self.assertIsNotNone(tracker_field2["revision_id"]) # Activate tracker self.assertTrue(TrackerFieldManagementInterface.activate_tracker_field( self.__admin_user_id, tracker_field_id2)) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"])
def test_create_tracker_fields(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) self.assertTrue( TrackerFieldManagementInterface.create_tracker_fields( self.__admin_user_id, tracker_id1, [{ "name": "test1", "display_name": "Test 1", "description": "Test tracker field 1", "field_type": "artifact_id", "required": True }, { "name": "test2", "display_name": "Test 2", "description": "Test tracker field 2", "field_type": "artifact_id", "required": False }])) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1) self.assertEqual(len(tracker_field_ids), 2) tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_ids[0]) self.assertEqual(tracker_field1["id"], tracker_field_ids[0]) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], True) self.assertIsNotNone(tracker_field1["revision_id"]) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_ids[1]) self.assertEqual(tracker_field2["id"], tracker_field_ids[1]) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"])
def test_create_tracker_fields(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) self.assertTrue(TrackerFieldManagementInterface.create_tracker_fields( self.__admin_user_id, tracker_id1, [{"name": "test1", "display_name": "Test 1", "description": "Test tracker field 1", "field_type": "artifact_id", "required": True}, {"name": "test2", "display_name": "Test 2", "description": "Test tracker field 2", "field_type": "artifact_id", "required": False} ])) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids(tracker_id1) self.assertEqual(len(tracker_field_ids), 2) tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_ids[0]) self.assertEqual(tracker_field1["id"], tracker_field_ids[0]) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], True) self.assertIsNotNone(tracker_field1["revision_id"]) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_ids[1]) self.assertEqual(tracker_field2["id"], tracker_field_ids[1]) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"])
def create_tracker_field_test2(self, tracker_id: int): tracker_field_id = TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id, "test2", "Test 2", "Test tracker field 2", "artifact_id", False) return tracker_field_id
def test_create_tracker_field(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) # Positive tests --------------------------------------------------------------------------- self.assertIsNotNone(self.create_tracker_field_test1(tracker_id1)) # Negative tests --------------------------------------------------------------------------- # Try to create a tracker field with a reference to a non-existing user self.assertIsNone( TrackerFieldManagementInterface.create_tracker_field( 999, tracker_id1, "test_other", "Test Other", "Other test tracker field", "artifact_id", True)) # Try to create a tracker field with a reference to a non-existing tracker self.assertIsNone( TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, 999, "test_other", "Test Other", "Other test tracker field", "artifact_id", True)) # Try to create a tracker field with an invalid name self.assertIsNone( TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "", "Test Other", "Other test tracker field", "artifact_id", True)) self.assertIsNone( TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "test1", "Test Other", "Other test tracker field", "artifact_id", True)) # Try to create a tracker field with an invalid display name self.assertIsNone( TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "test_other", "", "Other test tracker field", "artifact_id", True)) self.assertIsNone( TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "test_other", "Test 1", "Other test tracker field", "artifact_id", True))
def test_read_all_tracker_field_ids(self): # Create tracker fields project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id1) self.assertIsNotNone(tracker_field1) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertIsNotNone(tracker_field2) # Check active tracker fields (latest revision) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active) self.assertEqual(len(tracker_field_ids), 2) self.assertListEqual(tracker_field_ids, [tracker_field_id1, tracker_field_id2]) # Check active tracker fields (revision from tracker_field2) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active, tracker_field2["revision_id"]) self.assertEqual(len(tracker_field_ids), 2) self.assertListEqual(tracker_field_ids, [tracker_field_id1, tracker_field_id2]) # Check active tracker fields (revision from tracker_field1) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active, tracker_field1["revision_id"]) self.assertEqual(len(tracker_field_ids), 1) self.assertListEqual(tracker_field_ids, [tracker_field_id1]) # Deactivate tracker field self.assertTrue(TrackerFieldManagementInterface.deactivate_tracker_field( self.__admin_user_id, tracker_field_id1)) # Recheck active tracker fields (revision from tracker2) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active, tracker_field2["revision_id"]) self.assertEqual(len(tracker_field_ids), 2) self.assertListEqual(tracker_field_ids, [tracker_field_id1, tracker_field_id2]) # Recheck active tracker fields (latest revision) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active) self.assertEqual(len(tracker_field_ids), 1) self.assertListEqual(tracker_field_ids, [tracker_field_id2]) # Check inactive tracker fields (latest revision) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Inactive) self.assertEqual(len(tracker_field_ids), 1) self.assertListEqual(tracker_field_ids, [tracker_field_id1]) # Check inactive tracker fields (revision from tracker_field2) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Inactive, tracker_field2["revision_id"]) self.assertEqual(len(tracker_field_ids), 0)
def test_update_tracker_field_display_name(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id1) self.assertIsNotNone(tracker_field1) self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], True) self.assertIsNotNone(tracker_field1["revision_id"]) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertIsNotNone(tracker_field2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Positive tests --------------------------------------------------------------------------- self.assertTrue(TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, tracker_field_id2, tracker_field2["name"], "Test other", tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"])) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id(tracker_field_id2) self.assertIsNotNone(tracker_field2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test other") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Negative tests --------------------------------------------------------------------------- self.assertFalse(TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, tracker_field_id2, tracker_field2["name"], "", tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"])) self.assertFalse(TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, tracker_field_id2, tracker_field2["name"], tracker_field1["display_name"], tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"]))
def test_create_tracker_field(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) # Positive tests --------------------------------------------------------------------------- self.assertIsNotNone(self.create_tracker_field_test1(tracker_id1)) # Negative tests --------------------------------------------------------------------------- # Try to create a tracker field with a reference to a non-existing user self.assertIsNone(TrackerFieldManagementInterface.create_tracker_field( 999, tracker_id1, "test_other", "Test Other", "Other test tracker field", "artifact_id", True)) # Try to create a tracker field with a reference to a non-existing tracker self.assertIsNone(TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, 999, "test_other", "Test Other", "Other test tracker field", "artifact_id", True)) # Try to create a tracker field with an invalid name self.assertIsNone(TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "", "Test Other", "Other test tracker field", "artifact_id", True)) self.assertIsNone(TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "test1", "Test Other", "Other test tracker field", "artifact_id", True)) # Try to create a tracker field with an invalid display name self.assertIsNone(TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "test_other", "", "Other test tracker field", "artifact_id", True)) self.assertIsNone(TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id1, "test_other", "Test 1", "Other test tracker field", "artifact_id", True))
def test_read_tracker_fields_by_display_name(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) self.assertTrue(TrackerFieldManagementInterface.deactivate_tracker_field( self.__admin_user_id, tracker_field_id1)) tracker_field_id2 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id2) # Positive tests --------------------------------------------------------------------------- tracker_fields = \ TrackerFieldManagementInterface.read_tracker_fields_by_display_name("Test 1") self.assertEqual(len(tracker_fields), 2) tracker_field1 = tracker_fields[0] tracker_field2 = tracker_fields[1] self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], False) self.assertIsNotNone(tracker_field1["revision_id"]) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test1") self.assertEqual(tracker_field2["display_name"], "Test 1") self.assertEqual(tracker_field2["description"], "Test tracker field 1") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], True) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) tracker_fields = TrackerFieldManagementInterface.read_tracker_fields_by_display_name( tracker_field2["display_name"], tracker_field2["revision_id"] - 1) self.assertEqual(len(tracker_fields), 1) tracker_field1 = tracker_fields[0] self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], False) self.assertIsNotNone(tracker_field1["revision_id"]) # Negative tests --------------------------------------------------------------------------- self.assertEqual( len(TrackerFieldManagementInterface.read_tracker_fields_by_display_name("")), 0) self.assertEqual( len(TrackerFieldManagementInterface.read_tracker_fields_by_display_name("Test XYZ")), 0)
def test_read_tracker_fields_by_display_name(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) self.assertTrue( TrackerFieldManagementInterface.deactivate_tracker_field( self.__admin_user_id, tracker_field_id1)) tracker_field_id2 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id2) # Positive tests --------------------------------------------------------------------------- tracker_fields = \ TrackerFieldManagementInterface.read_tracker_fields_by_display_name("Test 1") self.assertEqual(len(tracker_fields), 2) tracker_field1 = tracker_fields[0] tracker_field2 = tracker_fields[1] self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], False) self.assertIsNotNone(tracker_field1["revision_id"]) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test1") self.assertEqual(tracker_field2["display_name"], "Test 1") self.assertEqual(tracker_field2["description"], "Test tracker field 1") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], True) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) tracker_fields = TrackerFieldManagementInterface.read_tracker_fields_by_display_name( tracker_field2["display_name"], tracker_field2["revision_id"] - 1) self.assertEqual(len(tracker_fields), 1) tracker_field1 = tracker_fields[0] self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], False) self.assertIsNotNone(tracker_field1["revision_id"]) # Negative tests --------------------------------------------------------------------------- self.assertEqual( len( TrackerFieldManagementInterface. read_tracker_fields_by_display_name("")), 0) self.assertEqual( len( TrackerFieldManagementInterface. read_tracker_fields_by_display_name("Test XYZ")), 0)
def test_read_all_tracker_field_ids(self): # Create tracker fields project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id1) self.assertIsNotNone(tracker_field1) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertIsNotNone(tracker_field2) # Check active tracker fields (latest revision) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active) self.assertEqual(len(tracker_field_ids), 2) self.assertListEqual(tracker_field_ids, [tracker_field_id1, tracker_field_id2]) # Check active tracker fields (revision from tracker_field2) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active, tracker_field2["revision_id"]) self.assertEqual(len(tracker_field_ids), 2) self.assertListEqual(tracker_field_ids, [tracker_field_id1, tracker_field_id2]) # Check active tracker fields (revision from tracker_field1) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active, tracker_field1["revision_id"]) self.assertEqual(len(tracker_field_ids), 1) self.assertListEqual(tracker_field_ids, [tracker_field_id1]) # Deactivate tracker field self.assertTrue( TrackerFieldManagementInterface.deactivate_tracker_field( self.__admin_user_id, tracker_field_id1)) # Recheck active tracker fields (revision from tracker2) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active, tracker_field2["revision_id"]) self.assertEqual(len(tracker_field_ids), 2) self.assertListEqual(tracker_field_ids, [tracker_field_id1, tracker_field_id2]) # Recheck active tracker fields (latest revision) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Active) self.assertEqual(len(tracker_field_ids), 1) self.assertListEqual(tracker_field_ids, [tracker_field_id2]) # Check inactive tracker fields (latest revision) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Inactive) self.assertEqual(len(tracker_field_ids), 1) self.assertListEqual(tracker_field_ids, [tracker_field_id1]) # Check inactive tracker fields (revision from tracker_field2) tracker_field_ids = TrackerFieldManagementInterface.read_all_tracker_field_ids( tracker_id1, TrackerFieldSelection.Inactive, tracker_field2["revision_id"]) self.assertEqual(len(tracker_field_ids), 0)
def test_update_tracker_field_display_name(self): project_id1 = self.create_project_test1() self.assertIsNotNone(project_id1) tracker_id1 = self.create_tracker_test1(project_id1) self.assertIsNotNone(tracker_id1) tracker_field_id1 = self.create_tracker_field_test1(tracker_id1) self.assertIsNotNone(tracker_field_id1) tracker_field1 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id1) self.assertIsNotNone(tracker_field1) self.assertEqual(tracker_field1["id"], tracker_field_id1) self.assertEqual(tracker_field1["tracker_id"], tracker_id1) self.assertEqual(tracker_field1["name"], "test1") self.assertEqual(tracker_field1["display_name"], "Test 1") self.assertEqual(tracker_field1["description"], "Test tracker field 1") self.assertEqual(tracker_field1["field_type"], "artifact_id") self.assertEqual(tracker_field1["required"], True) self.assertEqual(tracker_field1["active"], True) self.assertIsNotNone(tracker_field1["revision_id"]) tracker_field_id2 = self.create_tracker_field_test2(tracker_id1) self.assertIsNotNone(tracker_field_id2) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertIsNotNone(tracker_field2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test 2") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Positive tests --------------------------------------------------------------------------- self.assertTrue( TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, tracker_field_id2, tracker_field2["name"], "Test other", tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"])) tracker_field2 = TrackerFieldManagementInterface.read_tracker_field_by_id( tracker_field_id2) self.assertIsNotNone(tracker_field2) self.assertEqual(tracker_field2["id"], tracker_field_id2) self.assertEqual(tracker_field2["tracker_id"], tracker_id1) self.assertEqual(tracker_field2["name"], "test2") self.assertEqual(tracker_field2["display_name"], "Test other") self.assertEqual(tracker_field2["description"], "Test tracker field 2") self.assertEqual(tracker_field2["field_type"], "artifact_id") self.assertEqual(tracker_field2["required"], False) self.assertEqual(tracker_field2["active"], True) self.assertIsNotNone(tracker_field2["revision_id"]) # Negative tests --------------------------------------------------------------------------- self.assertFalse( TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, tracker_field_id2, tracker_field2["name"], "", tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"])) self.assertFalse( TrackerFieldManagementInterface.update_tracker_field_information( self.__admin_user_id, tracker_field_id2, tracker_field2["name"], tracker_field1["display_name"], tracker_field2["description"], tracker_field2["field_type"], tracker_field2["required"], tracker_field2["active"]))
def create_tracker_field_test2(self, tracker_id: int): tracker_field_id = TrackerFieldManagementInterface.create_tracker_field( self.__admin_user_id, tracker_id, "test2", "Test 2", "Test tracker field 2", "artifact_id", False) return tracker_field_id