def testPassSatisfied(self): # Check that error isn't raised when all skill requirements # are met fit = Fit() item = self.ch.type_(typeId=1) item.requiredSkills = {50: 3} holder = IndependentItem(item) fit.items.append(holder) skill = Skill(self.ch.type_(typeId=50)) skill.level = 3 fit.items.append(skill) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNone(restrictionError) fit.items.remove(holder) fit.items.remove(skill) self.assertBuffersEmpty(fit)
def testPassNone(self): # When typeIDs of skills are None, they should be ignored fit = Fit() item = self.ch.type_(typeId=None) skill1 = Skill(item) fit.items.add(skill1) skill2 = Skill(item) fit.items.add(skill2) restrictionError1 = fit.getRestrictionError(skill1, Restriction.skillUniqueness) self.assertIsNone(restrictionError1) restrictionError2 = fit.getRestrictionError(skill2, Restriction.skillUniqueness) self.assertIsNone(restrictionError2) fit.items.remove(skill1) fit.items.remove(skill2) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)
def testPassSatisfied(self): # Check that error isn't raised when all skill requirements # are met fit = Fit() item = self.ch.type_(typeId=1) item.requiredSkills = {50: 3} holder = IndependentItem(item) fit.items.add(holder) skill = Skill(self.ch.type_(typeId=50)) skill.level = 3 fit.items.add(skill) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNone(restrictionError) fit.items.remove(holder) fit.items.remove(skill) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)
def testFailPartial(self): # Make sure satisfied skill requirements are not shown # up in error fit = Fit() item = self.ch.type_(typeId=1) item.requiredSkills = {48: 1, 50: 5} holder = IndependentItem(item) fit.items.append(holder) skill = Skill(self.ch.type_(typeId=48)) skill.level = 5 fit.items.append(skill) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNotNone(restrictionError) self.assertCountEqual(restrictionError, ((50, None, 5),)) fit.items.remove(holder) fit.items.remove(skill) self.assertBuffersEmpty(fit)
def testFail(self): # Check that multiple skills with this ID raise error fit = Fit() item = self.ch.type_(typeId=56) skill1 = Skill(item) fit.items.add(skill1) skill2 = Skill(item) fit.items.add(skill2) restrictionError1 = fit.getRestrictionError(skill1, Restriction.skillUniqueness) self.assertIsNotNone(restrictionError1) self.assertEqual(restrictionError1.skill, 56) restrictionError2 = fit.getRestrictionError(skill2, Restriction.skillUniqueness) self.assertIsNotNone(restrictionError2) self.assertEqual(restrictionError2.skill, 56) fit.items.remove(skill1) fit.items.remove(skill2) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)
def testFailPartial(self): # Make sure satisfied skill requirements are not shown # up in error fit = Fit() item = self.ch.type_(typeId=1) item.requiredSkills = {48: 1, 50: 5} holder = IndependentItem(item) fit.items.add(holder) skill = Skill(self.ch.type_(typeId=48)) skill.level = 5 fit.items.add(skill) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNotNone(restrictionError) self.assertCountEqual(restrictionError, ((50, None, 5),)) fit.items.remove(holder) fit.items.remove(skill) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)
def testPassMultiSkill(self): # Make sure max skill level is taken fit = Fit() item1 = self.ch.type_(typeId=1) item1.requiredSkills = {50: 4} holder = IndependentItem(item1) fit.items.append(holder) item2 = self.ch.type_(typeId=50) skill1 = Skill(item2) skill1.level = 1 fit.items.append(skill1) skill2 = Skill(item2) skill2.level = 5 fit.items.append(skill2) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNone(restrictionError) fit.items.remove(holder) fit.items.remove(skill1) fit.items.remove(skill2)
def testPass(self): # No error should be raised when single skill # is added to fit fit = Fit() skill = Skill(self.ch.type_(typeId=56)) fit.items.add(skill) restrictionError = fit.getRestrictionError(skill, Restriction.skillUniqueness) self.assertIsNone(restrictionError) fit.items.remove(skill) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)
def testPassMultiSkillNone(self): # Make sure that None-leveled skills are overridden # by skills which have some skill level fit = Fit() item1 = self.ch.type_(typeId=1) item1.requiredSkills = {50: 0} holder = IndependentItem(item1) fit.items.append(holder) item2 = self.ch.type_(typeId=50) skill1 = Skill(item2) skill1.level = None fit.items.append(skill1) skill2 = Skill(item2) skill2.level = 0 fit.items.append(skill2) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNone(restrictionError) fit.items.remove(holder) fit.items.remove(skill1) fit.items.remove(skill2) self.assertBuffersEmpty(fit)
def testPassMultiSkill(self): # Make sure max skill level is taken fit = Fit() item1 = self.ch.type_(typeId=1) item1.requiredSkills = {50: 4} holder = IndependentItem(item1) fit.items.add(holder) item2 = self.ch.type_(typeId=50) skill1 = Skill(item2) skill1.level = 1 fit.items.add(skill1) skill2 = Skill(item2) skill2.level = 5 fit.items.add(skill2) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNone(restrictionError) fit.items.remove(holder) fit.items.remove(skill1) fit.items.remove(skill2) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)
def testPassMultiSkillNone(self): # Make sure that None-leveled skills are overridden # by skills which have some skill level fit = Fit() item1 = self.ch.type_(typeId=1) item1.requiredSkills = {50: 0} holder = IndependentItem(item1) fit.items.add(holder) item2 = self.ch.type_(typeId=50) skill1 = Skill(item2) skill1.level = None fit.items.add(skill1) skill2 = Skill(item2) skill2.level = 0 fit.items.add(skill2) restrictionError = fit.getRestrictionError(holder, Restriction.skillRequirement) self.assertIsNone(restrictionError) fit.items.remove(holder) fit.items.remove(skill1) fit.items.remove(skill2) self.assertEqual(len(self.log), 0) self.assertRestrictionBuffersEmpty(fit)