コード例 #1
0
def test_StringColumn_prepare_string_sanitizes_then_limits_chars(monkeypatch):
    sc = columns.StringColumn('test', False, 10, True)

    def mock_sanitize_string(some_string):
        return some_string + ' sanitized'
    monkeypatch.setattr(sc, '_Column__sanitize_string', mock_sanitize_string)
    actual_str = sc.prepare_string('test str')
    expect_str = 'test str s'
    assert actual_str == expect_str
コード例 #2
0
ファイル: image.py プロジェクト: tushar912/cccatalog
from collections import namedtuple
from datetime import datetime
import logging
import os

from common.licenses import licenses
from common.storage import util
from common.storage import columns

logger = logging.getLogger(__name__)

_IMAGE_TSV_COLUMNS = [
    # The order of this list maps to the order of the columns in the TSV.
    columns.StringColumn(name='foreign_identifier',
                         required=False,
                         size=3000,
                         truncate=False),
    columns.URLColumn(name='foreign_landing_url', required=True, size=1000),
    columns.URLColumn(
        # `url` in DB
        name='image_url',
        required=True,
        size=3000),
    columns.URLColumn(
        # `thumbnail` in DB
        name='thumbnail_url',
        required=False,
        size=3000),
    columns.IntegerColumn(name='width', required=False),
    columns.IntegerColumn(name='height', required=False),
    columns.IntegerColumn(name='filesize', required=False),