def test_edit_preclude_duplicate_modules(self): ''' Tests editing preclusion on a module to precludes with duplicates, note: this test case should fail to edit. ''' if not self.edit_preclude_duplicate_tested: model.add_preclusion(self.test_module_code, self.test_preclude_code) preclude_units_to_change_to = [ self.test_preclude2_code, self.test_preclude2_code ] outcome = model.edit_preclusion(self.test_module_code, preclude_units_to_change_to) assert_false(outcome[0]) error_list = outcome[1] assert_equal(len(error_list), 1) assert_equal( error_list[0], [self.test_preclude2_code, self.ERROR_MSG_MODULE_DUPLICATED]) preclude_info = model.get_preclusion(self.test_module_code) assert_true(preclude_info is not None) assert_equal(self.test_preclude_code, preclude_info[0][0]) model.delete_all_preclusions(self.test_module_code) preclude_info = model.get_preclusion(self.test_module_code) assert_true(len(preclude_info) == 0)
def test_preclude_to_multiple_preclude(self): ''' Tests editing preclusion on a module to multiple preclude. ''' if not self.preclude_to_multiple_preclude_tested: model.add_preclusion(self.test_module_code, self.test_preclude_code) preclude_units_to_change_to = [ self.test_preclude_code, self.test_preclude2_code, self.test_preclude3_code ] outcome = model.edit_preclusion(self.test_module_code, preclude_units_to_change_to) assert_true(outcome[0]) preclude_info = model.get_preclusion(self.test_module_code) assert_true(preclude_info is not None) assert_equal(len(preclude_info), 3) assert_equal(self.test_preclude_code, preclude_info[0][0]) assert_equal(self.test_preclude2_code, preclude_info[1][0]) assert_equal(self.test_preclude3_code, preclude_info[2][0]) model.delete_all_preclusions(self.test_module_code) preclude_info = model.get_preclusion(self.test_module_code) assert_true(len(preclude_info) == 0) return
def test_preclude_delete_all(self): ''' Tests deleting all preclusions of specific module. ''' if not self.preclude_delete_all_tested: model.add_module(self.test_preclude_code, self.test_module_name, self.test_module_desc, self.test_module_mc, self.test_module_status) model.add_module(self.test_preclude_code2, self.test_module_name, self.test_module_desc, self.test_module_mc, self.test_module_status) model.add_preclusion(self.test_module_code, self.test_preclude_code) model.add_preclusion(self.test_module_code, self.test_preclude_code2) outcome = model.delete_all_preclusions(self.test_module_code) assert_true(outcome) preclude_info_1 = model.get_preclusion(self.test_preclude_code) preclude_info_2 = model.get_preclusion(self.test_preclude_code2) preclude_info_3 = model.get_preclusion(self.test_module_code) model.delete_module(self.test_preclude_code) model.delete_module(self.test_preclude_code2) assert_true(len(preclude_info_1) == 0) assert_true(len(preclude_info_2) == 0) assert_true(len(preclude_info_3) == 0) return
def test_no_preclude_to_one_preclude(self): ''' Tests editing preclusion on a module originally with no preclude to 1 preclude. ''' if not self.no_preclude_to_one_preclude_tested: preclude_units_to_change_to = [self.test_preclude_code] outcome = model.edit_preclusion(self.test_module_code, preclude_units_to_change_to) assert_true(outcome[0]) preclude_info = model.get_preclusion(self.test_module_code) assert_true(preclude_info is not None) assert_equal(len(preclude_info), 1) assert_equal(self.test_preclude_code, preclude_info[0][0]) model.delete_all_preclusions(self.test_module_code) preclude_info = model.get_preclusion(self.test_module_code) assert_true(len(preclude_info) == 0) return
def test_edit_preclude_multiple_errors(self): ''' Tests editing preclusion on a module to precludes with multiple errors. Note: this test case should fail to edit. ''' if not self.edit_preclude_multiple_errors_tested: model.add_preclusion(self.test_module_code, self.test_preclude_code) preclude_units_to_change_to = [ self.test_module_code, self.test_invalid_module_code ] outcome = model.edit_preclusion(self.test_module_code, preclude_units_to_change_to) assert_false(outcome[0]) error_list = outcome[1] assert_equal(len(error_list), 2) assert_equal(error_list[0], [ self.test_module_code, self.ERROR_MSG_MODULE_CANNOT_BE_ITSELF ]) assert_equal(error_list[1], [ self.test_invalid_module_code, self.ERROR_MSG_MODULE_DOESNT_EXIST ]) preclude_info = model.get_preclusion(self.test_module_code) assert_true(preclude_info is not None) assert_equal(self.test_preclude_code, preclude_info[0][0]) model.delete_all_preclusions(self.test_module_code) preclude_info = model.get_preclusion(self.test_module_code) assert_true(len(preclude_info) == 0)
def test_edit_preclude_non_existent_modules(self): ''' Tests editing preclusion on a module to precludes which does not exist, note: this test case should fail to edit. ''' if not self.edit_preclude_non_existent_tested: model.add_preclusion(self.test_module_code, self.test_preclude_code) preclude_units_to_change_to = [ self.test_preclude2_code, self.test_invalid_module_code ] outcome = model.edit_preclusion(self.test_module_code, preclude_units_to_change_to) assert_false(outcome[0]) error_list = outcome[1] assert_equal(len(error_list), 1) assert_equal(error_list[0], [ self.test_invalid_module_code, self.ERROR_MSG_MODULE_DOESNT_EXIST ]) preclude_info = model.get_preclusion(self.test_module_code) assert_true(preclude_info is not None) assert_equal(self.test_preclude_code, preclude_info[0][0]) model.delete_all_preclusions(self.test_module_code) preclude_info = model.get_preclusion(self.test_module_code) assert_true(len(preclude_info) == 0) # Test another form model.add_preclusion(self.test_module_code, self.test_preclude_code) preclude_units_to_change_to = [ self.test_invalid_module_code, self.test_preclude2_code ] outcome = model.edit_preclusion(self.test_module_code, preclude_units_to_change_to) assert_false(outcome[0]) error_list = outcome[1] assert_equal(len(error_list), 1) assert_equal(error_list[0], [ self.test_invalid_module_code, self.ERROR_MSG_MODULE_DOESNT_EXIST ]) preclude_info = model.get_preclusion(self.test_module_code) assert_true(preclude_info is not None) assert_equal(self.test_preclude_code, preclude_info[0][0]) model.delete_all_preclusions(self.test_module_code) preclude_info = model.get_preclusion(self.test_module_code) assert_true(len(preclude_info) == 0) return