def test_split_filename(self): names = [("file", ".md"), ("file", ".tex"), ("file.md", ".pdf"), ("file-with_extra.symbols", ".txt")] for n in names: with self.subTest(n=n): name = n[0] + n[1] res = Utils.split_filename(name) self.assertEqual(res[0], n[0]) self.assertEqual(res[1], n[1])
def output_name(input, output=None): if output is None: splitted = Utils.split_filename(input[0]) if splitted[1] in _lo_can_convert: raise ValueErrorLO() elif splitted[1] == ".pdf": raise ValueErrorPdf("Input file already is PDF") return splitted[0] + ".pdf" else: return output
def output_name(input, output=None): if output is None: splited = Utils.split_filename(input[0]) if splited[1] in _lo_can_convert: raise ValueErrorLO() elif splited[1] == ".pdf": raise ValueErrorPdf("Input file already is PDF") return splited[0] + ".pdf" else: return output
def test_pict_time(self): texts = [ self.time + " " + self.rawtext, " " + self.time + " " + self.rawtext, self.time + "* " + self.rawtext ] expected = (self.time, self.rawtext) for t in texts: with self.subTest(t=t, expected=expected): returned = Utils.pick_time(t) self.assertEqual(returned, expected)
def __init__(self, user, baseUrl, projectName, month='last'): """ :param user: user in redmine :param baseUrl: base url of redmine instance, like http://redmine.example.com :type baseUrl: string :param projectName: name of project (multiple project are not allowed) :param month: """ self.baseUrl = baseUrl self.interval = Utils.define_interval(month) self.redmine = None try: self.redmine = Redmine(self.baseUrl) except Exception as e: print("Nelze se připojit k Redmine :(: %s" % e ) exit() self.user = self.get_user(user) self.project = self.redmine.project.get(projectName)
def __init__(self, user, baseUrl, projectName, **kwargs): """ :param user: user in redmine :param baseUrl: base url of redmine instance, like http://redmine.example.com :type baseUrl: string :param projectName: name of project (multiple project are not allowed) :param month: str default is last :param ssl: bool verify ssl certificate? """ month = kwargs.get('month', 'last') ssl_verify = kwargs.get('ssl', False) year = kwargs.get('ssl', datetime.date.today().year) self.baseUrl = baseUrl self.interval = Utils.define_interval(month, year=year) self.redmine = None try: self.redmine = Redmine(self.baseUrl, requests={'verify': ssl_verify}) except Exception as e: print("Nelze se připojit k Redmine :(: %s" % e ) exit() self.user = self.get_user(user) self.project = self.redmine.project.get(projectName)
def __init__(self, user, baseUrl, projectName, **kwargs): """ :param user: user in redmine :param baseUrl: base url of redmine instance, like http://redmine.example.com :type baseUrl: string :param projectName: name of project (multiple project are not allowed) :param month: str default is last :param ssl: bool verify ssl certificate? """ month = kwargs.get('month', 'last') ssl_verify = kwargs.get('ssl', False) year = int(kwargs.get('year', datetime.date.today().year)) self.refundace = kwargs.get('refundace', True) self.baseUrl = baseUrl self.interval = Utils.define_interval(month, year=year) self.redmine = None try: self.redmine = Redmine(self.baseUrl, requests={'verify': ssl_verify}) except Exception as e: print("Nelze se připojit k Redmine :(: %s" % e) exit() self.user = self.get_user(user) self.project = self.redmine.project.get(projectName)
def test_pick_time_fail(self): real = Utils.pick_time(self.rawtext) expect = ("?", self.rawtext) self.assertEqual(real, expect)
def test_pick_time_ok3(self): text = self.time + "* " + self.rawtext real = Utils.pick_time(text) expect = (self.time, self.rawtext) self.assertEqual(real, expect)
def test_interval_april(self): real = Utils.define_interval('April', 2015) firstJan = datetime.date(2015, 4, 1) lastJan = datetime.date(2015, 4, 30) expect = (firstJan, lastJan, "April") self.assertEqual(real, expect)
def test_interval_january(self): real = Utils.define_interval('January', 2015) firstJan = datetime.date(2015, 1, 1) lastJan = datetime.date(2015, 1, 31) expect = (firstJan, lastJan, "January") self.assertEqual(real, expect)
def test_interval_duben(self): real = Utils.define_interval('duben', 2015) firstJan = datetime.date(2015, 4, 1) lastJan = datetime.date(2015, 4, 30) expect = (firstJan, lastJan, "duben") self.assertEqual(real, expect)
def test_interval_leden(self): real = Utils.define_interval('leden', 2015) firstJan = datetime.date(2015, 1, 1) lastJan = datetime.date(2015, 1, 31) expect = (firstJan, lastJan, "leden") self.assertEqual(real, expect)
def test_pict_time_1_digit(self): returned = Utils.pick_time("9:00-10:00 text") expected = ("9:00-10:00", "text") self.assertEqual(returned, expected)
def test_pick_time_fail(self): returned = Utils.pick_time(self.rawtext) expected = ("?", self.rawtext) self.assertEqual(returned, expected)