def test_minion_hash_validator(self): #test default mv = MinionHashValidator() assert mv.to_python({'fedora':1,'debian':2,'others':3}) == {'fedora':1,'debian':2,'others':3} del mv #test with regex mv = MinionHashValidator(regex_string='^[A-Z]+$',not_empty=True) assert mv.to_python({'FEDORA':'FEDORA','MACOSX':'MACOSX'}) == {'FEDORA':'FEDORA','MACOSX':'MACOSX'} self.assertRaises(validators.Invalid,mv.to_python,{}) self.assertRaises(validators.Invalid,mv.to_python,{'hey_error':12}) self.assertRaises(validators.Invalid,mv.to_python,"hwy") del mv print "Happy testing !"
def test_minion_hash_validator(self): #test default mv = MinionHashValidator() assert mv.to_python([{'keyfield':'keyvalue','valuefield':'valuehere'}]) == {'keyvalue':'valuehere'} del mv #test with regex mv = MinionHashValidator(regex_string='^[A-Z]+$',not_empty=True) assert mv.to_python([{'keyfield':'FEDORA','valuefield':'MACOSX'}]) == {'FEDORA':'MACOSX'} self.assertRaises(validators.Invalid,mv.to_python,{}) self.assertRaises(validators.Invalid,mv.to_python,[{'keyfield':12,'valuefield':123}]) self.assertRaises(TypeError,mv.to_python,"hwy") del mv print "Happy testing !"
def test_minion_hash_validator(self): #test default mv = MinionHashValidator() assert mv.to_python([{ 'keyfield': 'keyvalue', 'valuefield': 'valuehere' }]) == { 'keyvalue': 'valuehere' } del mv #test with regex mv = MinionHashValidator(regex_string='^[A-Z]+$', not_empty=True) assert mv.to_python([{ 'keyfield': 'FEDORA', 'valuefield': 'MACOSX' }]) == { 'FEDORA': 'MACOSX' } self.assertRaises(validators.Invalid, mv.to_python, {}) self.assertRaises(validators.Invalid, mv.to_python, [{ 'keyfield': 12, 'valuefield': 123 }]) self.assertRaises(TypeError, mv.to_python, "hwy") del mv print "Happy testing !"