예제 #1
0
        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
예제 #2
0
        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
예제 #3
0
 class OrderSubmit(Froshki):
     order_id = Attribute()
     order_date = Attribute()
     order_owner = Attribute()
     address = Attribute()
     billing_to = Attribute()
     item_ids = Attribute()
     item_volumes = Attribute()
예제 #4
0
    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')
예제 #5
0
 class AdminLogin(Froshki):
     user_id = Attribute()
     password = Attribute()
     default_values = {
         'user_id': 'root',
     }
예제 #6
0
 class Configuration(Froshki):
     filter_level = Attribute()
     prediction = Attribute()
     items_per_page = Attribute()
예제 #7
0
 class Search(Froshki):
     search_key = Attribute(key_alias='key')
예제 #8
0
 class ResourceAccess(Froshki):
     resource_id = Attribute()
     user_id = Attribute()
     resource_key = ResouceKey(key_alias='password')
예제 #9
0
 class LikeSwitch(Froshki, Switch):
     uri = Attribute()
     user = Attribute()
     date_liked = Attribute()
예제 #10
0
 class Switch(object):
     on = Attribute()
예제 #11
0
 class LikeSwitch(Like):
     like_on = Attribute()
예제 #12
0
 class Like(Froshki):
     uri = Attribute()
     user = Attribute()
     date_liked = Attribute()
예제 #13
0
 class RegisterFormInput(Froshki):
     user_id = Attribute()
     user_name = Attribute()
     user_age = Attribute()
     password = Attribute()