def testUnicodeURLResolver(self): ''' Similarly to testURLResolver, it tests whether get_document_value does not throw an exception. This time, the value with unicode characters is provided. ''' settings.ROOT_URLCONF = 'examples.blog.urls' # Some unicode characters email = u"ąćźżńłóśę@gmail.com" u = NewUser(email=email) u.id=ObjectId('abcabcabcabc') p = Post(author=u, title='Test Post') p.id = ObjectId('abcabcabcabc') unicode_ok = False try: res = get_document_value(p, 'author') unicode_ok = True except UnicodeEncodeError, e: pass
def testURLResolver(self): ''' Tests whether reverse function inside get_document_value can correctly return a document_detail url when given a set of: <document_name> <app_label> and <id> Both <document_name> and <app_label> will contain dots, eg. <document_name> : 'User.NewUser' <app_label> : 'examples.blog.articles' ''' urls_tmp = settings.ROOT_URLCONF settings.ROOT_URLCONF = 'examples.blog.urls' u = NewUser(email='*****@*****.**') u.id=ObjectId('abcabcabcabc') p = Post(author=u, title='Test') p.id = ObjectId('abcabcabcabc') match_found = True try: v = get_document_value(p, 'author') except NoReverseMatch, e: match_found = False
def testUnicodeURLResolver(self): """ Similarly to testURLResolver, it tests whether get_document_value does not throw an exception. This time, the value with unicode characters is provided. """ settings.ROOT_URLCONF = 'examples.blog.urls' # Some unicode characters email = u"ąćźżńłóśę@gmail.com" u = NewUser(email=email) u.id = ObjectId('666f6f2d6261722d71757578') p = Post(author=u, title='Test Post') p.id = ObjectId('666f6f2d6261722d71757578') unicode_ok = False try: res = get_document_value(p, 'author') unicode_ok = True except UnicodeEncodeError as e: pass self.assertTrue(unicode_ok)