class User(Document):
    email = StringField(required=True)
    first_name = StringField(max_length=50)
    last_name = StringField(max_length=50)
    is_admin = BooleanField(default=True)

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
Пример #2
0
class User(Document):
    __collection__ = "AggregationUser"

    email = StringField(required=True)
    first_name = StringField(max_length=50, default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    updated_at = DateTimeField(required=True, auto_now_on_insert=True, auto_now_on_update=True)
    number_of_documents = IntField()
    list_items = ListField(IntField())
Пример #3
0
class ApiTestData(ProjectDataDocument):
    """
    测试数据统计表---因为性能问题,取消使用 2016-09-30
    """
    __collection__ = "api_test_data"

    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = StringField(max_length=1024)
Пример #4
0
class User(Document):
    email = StringField(required=True)
    first_name = StringField(max_length=50, default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    website = URLField(default="http://google.com/")
    updated_at = DateTimeField(required=True,
                               auto_now_on_insert=True,
                               auto_now_on_update=True)

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
Пример #5
0
class LimitTestData(MyDocument):
    """
    测试数据统计表
    """
    __collection__ = "limit_test_data"

    # id = ObjectId()
    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = StringField(max_length=1024)

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
Пример #6
0
class User(Document):
    email = StringField(required=True)
    first_name = StringField(db_field="whatever",
                             max_length=50,
                             default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    website = URLField(default="http://google.com/")
    updated_at = DateTimeField(required=True,
                               auto_now_on_insert=True,
                               auto_now_on_update=True)
    embedded = EmbeddedDocumentField(EmbeddedDocument,
                                     db_field="embedded_document")
    nullable = EmbeddedDocumentField(EmbeddedDocument,
                                     db_field="nullable_embedded_document")
    numbers = ListField(IntField())

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
Пример #7
0
class UnitTestData(MyDocument):
    """
    测试数据统计表--插入时没有使用,没有使用ORM
    """
    __collection__ = "unit_test_data"

    pro_version = StringField(max_length=1024)  # 项目版本号:1.2.3.4
    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = FloatField()
    details = ListField(ReferenceField(UnitTestDataDetail))

    # 数据归属
    project = ReferenceField(reference_document_type=Project)  # 测试数据所属的项目
    project_name = StringField()  # 项目名称,冗余
    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
Пример #8
0
class LanAppUser(UserBaseDocument):
    """
    内网应用的用户
    """
    __collection__ = "lan_app_users"
    is_active = BooleanField()
Пример #9
0
 def test_from_son(self):
     field = BooleanField()
     expect(field.from_son(1)).to_equal(True)
     expect(field.from_son(0)).to_equal(False)
Пример #10
0
    def test_to_son(self):
        field = BooleanField()

        expect(field.to_son(True)).to_equal(1)
        expect(field.to_son(False)).to_equal(0)