コード例 #1
0
def factory_entity_model(entity_info: dict = TestEntityInfo.entity1,
                         user_id=None):
    """Produce a templated entity model."""
    entity = EntityModel.create_from_dict(entity_info)
    entity.created_by_id = user_id
    entity.save()
    return entity
def test_create_from_dict(session):  # pylint:disable=unused-argument
    """Assert that an Entity can be created from schema."""
    updated_entity_info = {
        'businessIdentifier': 'CP1234567',
        'businessNumber': '791861073BC0001',
        'passCode': '9898989',
        'name': 'Barfoo, Inc.',
        'corp_type_code': 'CP'
    }

    result_entity = EntityModel.create_from_dict(updated_entity_info)

    assert result_entity.id is not None
    assert result_entity.corp_type_code == 'CP'
def test_create_from_dict_no_schema(session):  # pylint:disable=unused-argument
    """Assert that an Entity can not be created without schema."""
    result_entity = EntityModel.create_from_dict(None)

    assert result_entity is None