23 |
23 |
24 class TestParser(unittest.TestCase): |
24 class TestParser(unittest.TestCase): |
25 def test_com_expiration(self): |
25 def test_com_expiration(self): |
26 data = """ |
26 data = """ |
27 Status: ok |
27 Status: ok |
28 Updated Date: 14-apr-2008 |
28 Updated Date: 2017-03-31T07:36:34Z |
29 Creation Date: 14-apr-2008 |
29 Creation Date: 2013-02-21T19:24:57Z |
30 Expiration Date: 14-apr-2009 |
30 Registry Expiry Date: 2018-02-21T19:24:57Z |
31 |
31 |
32 >>> Last update of whois database: Sun, 31 Aug 2008 00:18:23 UTC <<< |
32 >>> Last update of whois database: Sun, 31 Aug 2008 00:18:23 UTC <<< |
33 """ |
33 """ |
34 w = WhoisEntry.load('urlowl.com', data) |
34 w = WhoisEntry.load('urlowl.com', data) |
35 expires = w.expiration_date.strftime('%Y-%m-%d') |
35 expires = w.expiration_date.strftime('%Y-%m-%d') |
36 self.assertEqual(expires, '2009-04-14') |
36 self.assertEqual(expires, '2018-02-21') |
37 |
37 |
38 def test_cast_date(self): |
38 def test_cast_date(self): |
39 dates = ['14-apr-2008', '2008-04-14'] |
39 dates = ['14-apr-2008', '2008-04-14'] |
40 for d in dates: |
40 for d in dates: |
41 r = cast_date(d).strftime('%Y-%m-%d') |
41 r = cast_date(d).strftime('%Y-%m-%d') |
86 |
86 |
87 # Compare each key |
87 # Compare each key |
88 for key in results: |
88 for key in results: |
89 total += 1 |
89 total += 1 |
90 result = results.get(key) |
90 result = results.get(key) |
|
91 if isinstance(result, list): |
|
92 result = [str(element) for element in result] |
91 if isinstance(result, datetime.datetime): |
93 if isinstance(result, datetime.datetime): |
92 result = str(result) |
94 result = str(result) |
93 expected = expected_results.get(key) |
95 expected = expected_results.get(key) |
94 if expected != result: |
96 if expected != result: |
95 print("%s \t(%s):\t %s != %s" % (domain, key, result, expected)) |
97 print("%s \t(%s):\t %s != %s" % (domain, key, result, expected)) |