File: test_util.py

package info (click to toggle)
mwclient 0.10.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 340 kB
  • sloc: python: 2,279; makefile: 5; sh: 5
file content (26 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# encoding=utf-8
from __future__ import print_function
import unittest
import time
from mwclient.util import parse_timestamp

if __name__ == "__main__":
    print()
    print("Note: Running in stand-alone mode. Consult the README")
    print("      (section 'Contributing') for advice on running tests.")
    print()


class TestUtil(unittest.TestCase):

    def test_parse_missing_timestamp(self):
        assert time.struct_time((0, 0, 0, 0, 0, 0, 0, 0, 0)) == parse_timestamp(None)

    def test_parse_empty_timestamp(self):
        assert time.struct_time((0, 0, 0, 0, 0, 0, 0, 0, 0)) == parse_timestamp('0000-00-00T00:00:00Z')

    def test_parse_nonempty_timestamp(self):
        assert time.struct_time((2015, 1, 2, 20, 18, 36, 4, 2, -1)) == parse_timestamp('2015-01-02T20:18:36Z')

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