class CreateEvent(Froshki): event_name = Attribute() event_start = Attribute() event_end = Attribute() @validation_hook.extend(error='event must start before the end') def check_event_duration(self): if self.event_start < self.event_end: return True else: return False
class ModifyPassword(Froshki): user_id = Attribute() old_password = Attribute() new_password = Attribute() confirm_new_password = Attribute() @validation_hook def confirm_password(self): if self.new_password == self.confirm_new_password: return True else: return False
class OrderSubmit(Froshki): order_id = Attribute() order_date = Attribute() order_owner = Attribute() address = Attribute() billing_to = Attribute() item_ids = Attribute() item_volumes = Attribute()
def test_attr_modification(self): class Search(Froshki): search_key = Attribute(key_alias='key') search = Search( key='japanese furoshiki') # __new__ called for the first time. self.assertTrue(search.validate()) # Append attribute. Search.search_type = Attribute(key_alias='type') search = Search( key='japanese furoshiki', type='image', ) self.assertTrue(search.validate()) self.assertEqual(search.search_key, 'japanese furoshiki') self.assertEqual(search.search_type, 'image') # Redefine attribute. if is_ipy: del Search.search_type Search.search_type = Attribute() with self.assertRaises(TypeError): search = Search(type='movie') search = Search( search_key='japanese furoshiki', search_type='movie', ) self.assertTrue(search.validate()) self.assertEqual(search.search_key, 'japanese furoshiki') self.assertEqual(search.search_type, 'movie') # Delete attribute. del Search.search_type with self.assertRaises(TypeError): search = Search(search_type='news') search = Search(search_key='russian pirozhki') self.assertTrue(search.validate()) self.assertEqual(search.search_key, 'russian pirozhki')
class AdminLogin(Froshki): user_id = Attribute() password = Attribute() default_values = { 'user_id': 'root', }
class Configuration(Froshki): filter_level = Attribute() prediction = Attribute() items_per_page = Attribute()
class Search(Froshki): search_key = Attribute(key_alias='key')
class ResourceAccess(Froshki): resource_id = Attribute() user_id = Attribute() resource_key = ResouceKey(key_alias='password')
class LikeSwitch(Froshki, Switch): uri = Attribute() user = Attribute() date_liked = Attribute()
class Switch(object): on = Attribute()
class LikeSwitch(Like): like_on = Attribute()
class Like(Froshki): uri = Attribute() user = Attribute() date_liked = Attribute()
class RegisterFormInput(Froshki): user_id = Attribute() user_name = Attribute() user_age = Attribute() password = Attribute()