from os import path
from unittest import TestCase

import utils

class TestUtils(TestCase):

    def test_tpl_dict(self):
        d = utils.tpl_dict()
        self.assertIsInstance(d, dict)
        self.assertEqual(d['timefmt'], utils.timefmt)

    def test_timefmt(self):
        t = utils.timefmt(1468191315)
        self.assertEqual(t, 'Sun, 10 Jul 2016 19:55:15 -0300')
        t = utils.timefmt(1468191315, '%Y%m%d %H:%M:%S %z')
        self.assertEqual(t, '20160710 19:55:15 -0300')

@@ -1,12 +1,22 @@
+import os%0A
 from os impo
@@ -96,16 +96,130 @@
 Case):%0A%0A
+    def chdir(self, dname):%0A        d = path.join(path.dirname(__file__), 'testdata', dname)%0A        os.chdir(d)%0A%0A
     def 
@@ -360,16 +360,122 @@
 timefmt)
+%0A        self.assertEqual(d%5B'url'%5D, utils.url)%0A        self.assertEqual(d%5B'static_url'%5D, utils.static_url)
 %0A%0A    de
@@ -657,16 +657,16 @@
 %25S %25z')%0A
-
         
@@ -696,24 +696,650 @@
 160710 19:55:15 -0300')%0A
+%0A    def test_url(self):%0A        r = utils.url('fake/url')%0A        self.assertEqual(r, '/fake/url')%0A%0A    def test_url_scan_mode(self):%0A        self.chdir('gendoc')%0A        utils.scan_mode('htdocs', 'htdocs/fake.md')%0A        r = utils.url('fake/url')%0A        self.assertEqual(r, 'fake/url')%0A%0A    def test_url_scan_mode_dotted(self):%0A        self.chdir('gendoc')%0A        utils.scan_mode('htdocs', 'htdocs/s1/s2/s3/fake.md')%0A        r = utils.url('fake/url')%0A        self.assertEqual(r, '../../../fake/url')%0A%0A    def test_static_url(self):%0A        r = utils.static_url('fake.url')%0A        self.assertEqual(r, '/static/fake.url')%0A

test url utils