Skip to content

Commit

Permalink
WikiTeam#292: added testcase to reproduce issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rfelten committed Feb 22, 2017
1 parent 651edd7 commit 38e6974
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions testing/test_dumpgenerator_offline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# This file is part of the wikiteam project.
#
# Copyright (C) 2017 Robert Felten - https://github.com/rfelten/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # q&d import hack, sorry
import unittest
from dumpgenerator import truncateFilename

# This file is intended to test offline functionality of the dumpgenerator.py.
# For all other tests see test_dumpgenerator.py


class TestDumpgeneratorOffline(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_truncateFilename(self):
""" Test if truncFilename() obey other['filenamelimit']"""
other = dict() # FIXME: get from dumpgenerator, but code base is a pre-OO mess
other['filenamelimit'] = 100
fn = u"Assortiment de différentes préparation à bases de légumes et féculents, bien sur servit avec de l'injara.JPG"
self.assertEqual(len(fn), 108)
self.assertEqual(len(fn.encode("utf-8")), 113) # chars like 'è' will extend length

fn_trunc = truncateFilename(other=other, filename=fn)
self.assertLessEqual(len(fn_trunc), other['filenamelimit'],
"trunced filename '%s' len of %d exceed limit of %d." %
(fn_trunc, len(fn_trunc), other['filenamelimit']))

if __name__ == '__main__':
unittest.main()

0 comments on commit 38e6974

Please sign in to comment.