diff options
author | Markus Holtermann <info@markusholtermann.eu> | 2013-01-30 20:56:55 +0100 |
---|---|---|
committer | Markus Holtermann <info@markusholtermann.eu> | 2013-01-30 20:56:55 +0100 |
commit | 2443c414af8901e89b1b55e126ab4867c2cf91e4 (patch) | |
tree | 54e734c0b42358c5c066cfe872d7c73d99ad77e3 /tests/test_format.py | |
parent | 41af0a769e8896b6df5baccfff31d5ccea3f7da8 (diff) | |
download | bvg-grabber-2443c414af8901e89b1b55e126ab4867c2cf91e4.tar.gz bvg-grabber-2443c414af8901e89b1b55e126ab4867c2cf91e4.tar.bz2 bvg-grabber-2443c414af8901e89b1b55e126ab4867c2cf91e4.zip |
Move hourformat and fullformat to separate module. Add and adjust tests
Diffstat (limited to 'tests/test_format.py')
-rw-r--r-- | tests/test_format.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_format.py b/tests/test_format.py new file mode 100644 index 0000000..9c3e35e --- /dev/null +++ b/tests/test_format.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import datetime +import unittest + +from bvggrabber.api import fullformat, hourformat +from bvggrabber.utils.format import int2bin + + +class TestFormats(unittest.TestCase): + + def test_int2bin(self): + nums = [(0b1101110, 7, '1101110'), + (0b0010001, 7, '0010001'), + (0b111111, 6, '111111'), + (0b00000001, 8, '00000001'), + (0b00111, 5, '00111'), + (0b00111, 8, '00000111'), + (0b1100011, 7, '1100011')] + for b, l, s in nums: + self.assertEqual(int2bin(b, l), s) + + def test_datetime_formats(self): + f = [(datetime.datetime(2013, 1, 2, 3, 4, 0), + "2013-01-02 03:04:00", "03:04"), + (datetime.datetime(2013, 1, 2), + "2013-01-02 00:00:00", "00:00"), + (datetime.datetime(2013, 1, 2, 3, 4, 30), + "2013-01-02 03:04:30", "03:04")] + for dt, sf, sh in f: + self.assertEqual(fullformat(dt), sf) + self.assertEqual(hourformat(dt), sh) |