MCPcopy Index your code
hub / github.com/clips/pattern / test_field

Method test_field

test/test_db.py:386–412  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

384 self.assertEqual(v4, "varchar(255)")
385
386 def test_field(self):
387 # Assert field() return value with different optional parameters.
388 # NAME TYPE DEFAULT INDEX OPTIONAL
389 for kwargs, f in (
390 (dict(name="id", type=db.INT), ("id", "integer", None, False, True)),
391 (dict(name="id", type=db.INT, index=db.PRIMARY), ("id", "integer", None, "primary", True)),
392 (dict(name="id", type=db.INT, index=db.UNIQUE), ("id", "integer", None, "unique", True)),
393 (dict(name="id", type=db.INT, index="0"), ("id", "integer", None, False, True)),
394 (dict(name="id", type=db.INT, index="1"), ("id", "integer", None, True, True)),
395 (dict(name="id", type=db.INT, index=True), ("id", "integer", None, True, True)),
396 (dict(name="id", type=db.INT, default=0), ("id", "integer", 0, False, True)),
397 (dict(name="name", type=db.STRING), ("name", "varchar(100)", None, False, True)),
398 (dict(name="name", type=db.STRING, optional=False), ("name", "varchar(100)", None, False, False)),
399 (dict(name="name", type=db.STRING, optional="0"), ("name", "varchar(100)", None, False, False)),
400 (dict(name="name", type=db.STRING(50)), ("name", "varchar(50)", None, False, True)),
401 (dict(name="price", type=db.FLOAT, default=0), ("price", "real", 0, False, True)),
402 (dict(name="show", type=db.BOOL), ("show", "tinyint(1)", None, False, True)),
403 (dict(name="show", type=db.BOOL, default=True), ("show", "tinyint(1)", True, False, True)),
404 (dict(name="show", type=db.BOOL, default=False), ("show", "tinyint(1)", False, False, True)),
405 (dict(name="date", type=db.DATE), ("date", "timestamp", "now", False, True)),
406 (dict(name="date", type=db.DATE, default=db.NOW), ("date", "timestamp", "now", False, True)),
407 (dict(name="date", type=db.DATE, default="1999-12-31 23:59:59"),
408 ("date", "timestamp", "1999-12-31 23:59:59", False, True))):
409 self.assertEqual(db.field(**kwargs), f)
410 # Assert primary_key() return value.
411 self.assertTrue(db.primary_key() == db.pk() == ("id", "integer", None, "primary", False))
412 print "pattern.db.field()"
413
414 def test_schema(self):
415 now1 = "current_timestamp"

Callers

nothing calls this directly

Calls 1

pkMethod · 0.80

Tested by

no test coverage detected