示例#1
0
class ServiceAccount(HashMapModel, metaclass=CamelCaseMeta):

    user_id = StringIdField(read_only=True)
    """
    User identifier on service.
    """

    first_name = StringField()
    """
    User first name on service.
    """

    last_name = StringField()
    """
    User last name on service.
    """

    user_name = StringIdField(read_only=True)
    """
    User username on service.
    """

    personalities = HashMapField(field_type=ModelField(
        model_class=Personality))
    """
示例#2
0
 def test_set_initialised_list(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     test_list[2] = {}
     test_list[3] = "hi"
     test_list.append("hi")
     self.assertEqual(test_list.__modified_data__,
                      ["2", "3", "4", "hi", "hi"])
示例#3
0
    def test_string_field(self):
        list_model = ListModel(['aaaa', 'bbbb', 'cccc'],
                               field_type=StringField())
        list_model.flat_data()

        list_model.pop()

        self._assert_equal_after_pickle(list_model)
示例#4
0
 def test_pop_element(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     test_list.pop(1)
     self.assertEqual(test_list.__modified_data__, ["2", "4", "6"])
     test_list.flat_data()
     test_list.pop(1)
     self.assertEqual(test_list.__modified_data__, ["2", "6"])
     self.assertEqual(test_list.__original_data__, ["2", "4", "6"])
示例#5
0
class User(PersistentModel):

    user_name = StringIdField(read_only=True)
    """
    User username on platform.
    """

    first_name = StringField()
    """
    User first name on platform.
    """

    last_name = StringField()
    """
    User lasr name on platform.
    """

    service_accounts = HashMapField(field_type=ModelField(
        model_class=ServiceAccount))
    """
示例#6
0
class Room(PersistentModel):
    service_id = StringIdField(read_only=True)
    """
    Service where is room.
    """

    room_id = StringIdField(read_only=True)
    """
    Room identifier on service.
    """

    title = StringField()
    """
    Room title.
    """

    type = StringIdField()
    """
    Room type
    """

    assistants = ArrayField(field_type=StringIdField(), read_only=True)
    """
示例#7
0
 def test_iter_flattered(self):
     initial_list = [2, 3, "4", 6]
     test_list = ListModel(initial_list, field_type=StringField())
     test_list.flat_data()
     for x in test_list:
         self.assertEquals(x, str(initial_list[test_list.index(x)]))
示例#8
0
 def test_delete_item_flattered(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     test_list.flat_data()
     del test_list[0]
     self.assertEqual(test_list[0], "3")
示例#9
0
 def test_get_items_flattered_list(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     test_list.flat_data()
     self.assertEqual(test_list[0], "2")
示例#10
0
 def test_get_items(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     self.assertEqual(test_list[0], "2")
示例#11
0
 def test_index_exception(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     self.assertRaises(ValueError, test_list.index, 7)
示例#12
0
 def test_extend_with_invalid_elements(self):
     test_list = ListModel([2, 3, "4", 6], field_type=StringField())
     test_list.extend([{}, 3.4])
     self.assertEqual(test_list.__modified_data__,
                      ["2", "3", "4", "6", "3.4"])
示例#13
0
    def test_list_field_conversion(self):
        test_list = ListModel([2, 3, "4", 6], field_type=StringField())

        self.assertEqual(test_list.__modified_data__, ["2", "3", "4", "6"])
示例#14
0
 def test_reverse(self):
     test_list = ListModel(["one", "two", "three", []],
                           field_type=StringField())
     test_list.reverse()
     self.assertEqual(["three", "two", "one"], list(test_list))
示例#15
0
class Personality(BaseModel):
    first_name = StringField()
    last_name = StringField()