Page MenuHome

test_utils.py
No OneTemporary

test_utils.py

# -*- encoding: utf-8 -*-
from bson import ObjectId
from werkzeug.exceptions import BadRequest
from common_test_class import AbstractPillarTest
class Str2idTest(AbstractPillarTest):
def test_happy(self):
from application.utils import str2id
def happy(str_id):
self.assertEqual(ObjectId(str_id), str2id(str_id))
happy(24 * 'a')
happy(12 * 'a')
happy(u'577e23ad98377323f74c368c')
def test_unhappy(self):
from application.utils import str2id
def unhappy(str_id):
self.assertRaises(BadRequest, str2id, str_id)
unhappy(13 * 'a')
unhappy(u'577e23ad 8377323f74c368c')
unhappy(u'김치') # Kimchi
unhappy('')
unhappy(u'')
unhappy(None)

File Metadata

Mime Type
text/x-python
Expires
Sat, Aug 15, 12:08 PM (1 d, 23 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6b/6a/7ebddec05fe2359f342360c993e7

Event Timeline