test/test_parser.py
author Egon Kidmose <kidmose@gmail.com>
Thu, 15 Feb 2018 15:00:18 +0100
branchfeature/test-missing-keys
changeset 166 6cbe4891d62a
parent 157 f091b6581d21
child 179 2fb992c480e4
permissions -rw-r--r--
test_parser.py: Fail on missing keys
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
70
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     1
from __future__ import print_function
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     2
from __future__ import unicode_literals
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     3
from __future__ import division
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     4
from __future__ import absolute_import
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     5
from future import standard_library
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     6
standard_library.install_aliases()
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
     7
from builtins import *
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
     8
import unittest
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
     9
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    10
import os
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    11
import sys
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    12
sys.path.append('../')
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    13
12
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
    14
import datetime
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    15
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    16
try:
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    17
    import json
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    18
except:
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    19
    import simplejson as json
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    20
from glob import glob
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    21
12
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
    22
from whois.parser import WhoisEntry, cast_date
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    23
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    24
class TestParser(unittest.TestCase):
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    25
    def test_com_expiration(self):
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    26
        data = """
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    27
        Status: ok
152
f614365ab91b Dealing properly when there are multiple dates
joan <aseques@gmail.com>
parents: 149
diff changeset
    28
        Updated Date: 2017-03-31T07:36:34Z
f614365ab91b Dealing properly when there are multiple dates
joan <aseques@gmail.com>
parents: 149
diff changeset
    29
        Creation Date: 2013-02-21T19:24:57Z
f614365ab91b Dealing properly when there are multiple dates
joan <aseques@gmail.com>
parents: 149
diff changeset
    30
        Registry Expiry Date: 2018-02-21T19:24:57Z
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    31
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    32
        >>> Last update of whois database: Sun, 31 Aug 2008 00:18:23 UTC <<<
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    33
        """
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    34
        w = WhoisEntry.load('urlowl.com', data)
12
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
    35
        expires = w.expiration_date.strftime('%Y-%m-%d')
152
f614365ab91b Dealing properly when there are multiple dates
joan <aseques@gmail.com>
parents: 149
diff changeset
    36
        self.assertEqual(expires, '2018-02-21')
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    37
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    38
    def test_cast_date(self):
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    39
        dates = ['14-apr-2008', '2008-04-14']
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    40
        for d in dates:
12
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
    41
            r = cast_date(d).strftime('%Y-%m-%d')
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    42
            self.assertEqual(r, '2008-04-14')
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    43
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    44
    def test_com_allsamples(self):
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    45
        """
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    46
        Iterate over all of the sample/whois/*.com files, read the data,
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    47
        parse it, and compare to the expected values in sample/expected/.
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    48
        Only keys defined in keys_to_test will be tested.
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    49
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    50
        To generate fresh expected value dumps, see NOTE below.
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    51
        """
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    52
        keys_to_test = ['domain_name', 'expiration_date', 'updated_date',
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    53
                        'creation_date', 'status']
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    54
        fail = 0
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    55
        total = 0
149
3aff6a7772b3 Improve path detection for the test directories in windows
joan <aseques@gmail.com>
parents: 135
diff changeset
    56
        whois_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'samples','whois','*')
3aff6a7772b3 Improve path detection for the test directories in windows
joan <aseques@gmail.com>
parents: 135
diff changeset
    57
        expect_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'samples','expected')
3aff6a7772b3 Improve path detection for the test directories in windows
joan <aseques@gmail.com>
parents: 135
diff changeset
    58
        for path in glob(whois_path):
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    59
            # Parse whois data
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    60
            domain = os.path.basename(path)
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    61
            with open(path) as whois_fp:
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    62
                data = whois_fp.read()
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    63
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    64
            w = WhoisEntry.load(domain, data)
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    65
            results = {key: w.get(key) for key in keys_to_test}
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    66
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    67
            # NOTE: Toggle condition below to write expected results from the
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    68
            # parse results This will overwrite the existing expected results.
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    69
            # Only do this if you've manually confirmed that the parser is
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    70
            # generating correct values at its current state.
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    71
            if False:
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    72
                def date2str4json(obj):
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    73
                    if isinstance(obj, datetime.datetime):
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    74
                        return str(obj)
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    75
                    raise TypeError(
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    76
                            '{} is not JSON serializable'.format(repr(obj)))
149
3aff6a7772b3 Improve path detection for the test directories in windows
joan <aseques@gmail.com>
parents: 135
diff changeset
    77
                outfile_name = os.path.join(expect_path, domain)
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    78
                with open(outfile_name, 'w') as outfil:
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    79
                    expected_results = json.dump(results, outfil,
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    80
                                                       default=date2str4json)
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    81
                continue
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    82
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    83
            # Load expected result
149
3aff6a7772b3 Improve path detection for the test directories in windows
joan <aseques@gmail.com>
parents: 135
diff changeset
    84
            with open(os.path.join(expect_path, domain)) as infil:
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    85
                expected_results = json.load(infil)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
    86
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    87
            # Compare each key
166
6cbe4891d62a test_parser.py: Fail on missing keys
Egon Kidmose <kidmose@gmail.com>
parents: 157
diff changeset
    88
            for key in set(results).union(set(expected_results)):
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    89
                total += 1
166
6cbe4891d62a test_parser.py: Fail on missing keys
Egon Kidmose <kidmose@gmail.com>
parents: 157
diff changeset
    90
                if key not in results:
6cbe4891d62a test_parser.py: Fail on missing keys
Egon Kidmose <kidmose@gmail.com>
parents: 157
diff changeset
    91
                    print("%s \t(%s):\t Missing in results" % (domain, key,))
6cbe4891d62a test_parser.py: Fail on missing keys
Egon Kidmose <kidmose@gmail.com>
parents: 157
diff changeset
    92
                    fail += 1
6cbe4891d62a test_parser.py: Fail on missing keys
Egon Kidmose <kidmose@gmail.com>
parents: 157
diff changeset
    93
                    continue
6cbe4891d62a test_parser.py: Fail on missing keys
Egon Kidmose <kidmose@gmail.com>
parents: 157
diff changeset
    94
                
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
    95
                result = results.get(key)
152
f614365ab91b Dealing properly when there are multiple dates
joan <aseques@gmail.com>
parents: 149
diff changeset
    96
                if isinstance(result, list):
f614365ab91b Dealing properly when there are multiple dates
joan <aseques@gmail.com>
parents: 149
diff changeset
    97
                    result = [str(element) for element in result]
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    98
                if isinstance(result, datetime.datetime):
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
    99
                    result = str(result)
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
   100
                expected = expected_results.get(key)
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
   101
                if expected != result:
70
1fe2c20adeba Python3 support
Johnny Wezel<j@wezel.name>
parents: 12
diff changeset
   102
                    print("%s \t(%s):\t %s != %s" % (domain, key, result, expected))
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
   103
                    fail += 1
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   104
0
ea0e45971cea initial commit to mercurial
Richard Baron Penman
parents:
diff changeset
   105
        if fail:
97
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
   106
            self.fail("%d/%d sample whois attributes were not parsed properly!"
44522cd37b07 Fixed tests. Also some UTF bugs (python2/3 hell)
Mario D. Santana <mario@elorangutan.com>
parents: 70
diff changeset
   107
                      % (fail, total))
12
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
   108
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
   109
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   110
    def test_ca_parse(self):
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   111
        data = """
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   112
        Domain name:           testdomain.ca
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   113
        Domain status:         registered
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   114
        Creation date:         2000/11/20
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   115
        Expiry date:           2020/03/08
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   116
        Updated date:          2016/04/29
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   117
        DNSSEC:                Unsigned
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   118
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   119
        Registrar:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   120
            Name:              Webnames.ca Inc.
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   121
            Number:            70
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   122
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   123
        Registrant:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   124
            Name:              Test Industries
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   125
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   126
        Administrative contact:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   127
            Name:              Test Person1
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   128
            Postal address:    Test Address
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   129
                               Test City, TestVille
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   130
            Phone:             +1.1235434123x123
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   131
            Fax:               +1.123434123
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   132
            Email:             testperson1@testcompany.ca
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   133
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   134
        Technical contact:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   135
            Name:              Test Persion2
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   136
            Postal address:    Other TestAddress
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   137
                               TestTown OCAS Canada
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   138
            Phone:             +1.09876545123
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   139
            Fax:               +1.12312993873
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   140
            Email:             testpersion2@testcompany.ca
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   141
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   142
        Name servers:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   143
            ns1.testserver1.net
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   144
            ns2.testserver2.net
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   145
        """
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   146
        expected_results = {
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   147
            "updated_date": "2016-04-29 00:00:00",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   148
            "registrant_name": [
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   149
                "Webnames.ca Inc.",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   150
                "Test Industries",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   151
                "Test Person1",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   152
                "Test Persion2"
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   153
            ],
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   154
            "fax": [
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   155
                "+1.123434123",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   156
                "+1.12312993873"
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   157
            ],
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   158
            "dnssec": "Unsigned",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   159
            "registrant_number": "70",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   160
            "expiration_date": "2020-03-08 00:00:00",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   161
            "domain_name": "testdomain.ca",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   162
            "creation_date": "2000-11-20 00:00:00",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   163
            "phone": [
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   164
                "+1.1235434123x123",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   165
                "+1.09876545123"
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   166
            ],
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   167
            "domain_status": "registered",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   168
            "emails": [
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   169
                "testperson1@testcompany.ca",
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   170
                "testpersion2@testcompany.ca"
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   171
            ]
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   172
        }
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   173
        self._parse_and_compare('testcompany.ca', data, expected_results)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   174
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   175
    def test_il_parse(self):
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   176
        data = """
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   177
            query:        python.org.il
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   178
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   179
            reg-name:     python
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   180
            domain:       python.org.il
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   181
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   182
            descr:        Arik Baratz
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   183
            descr:        PO Box 7775 PMB 8452
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   184
            descr:        San Francisco, CA
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   185
            descr:        94120
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   186
            descr:        USA
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   187
            phone:        +1 650 6441973
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   188
            e-mail:       hostmaster AT arik.baratz.org
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   189
            admin-c:      LD-AB16063-IL
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   190
            tech-c:       LD-AB16063-IL
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   191
            zone-c:       LD-AB16063-IL
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   192
            nserver:      dns1.zoneedit.com
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   193
            nserver:      dns2.zoneedit.com
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   194
            nserver:      dns3.zoneedit.com
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   195
            validity:     10-05-2018
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   196
            DNSSEC:       unsigned
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   197
            status:       Transfer Locked
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   198
            changed:      domain-registrar AT isoc.org.il 20050524 (Assigned)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   199
            changed:      domain-registrar AT isoc.org.il 20070520 (Transferred)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   200
            changed:      domain-registrar AT isoc.org.il 20070520 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   201
            changed:      domain-registrar AT isoc.org.il 20070520 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   202
            changed:      domain-registrar AT isoc.org.il 20070807 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   203
            changed:      domain-registrar AT isoc.org.il 20071025 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   204
            changed:      domain-registrar AT isoc.org.il 20071025 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   205
            changed:      domain-registrar AT isoc.org.il 20081221 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   206
            changed:      domain-registrar AT isoc.org.il 20081221 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   207
            changed:      domain-registrar AT isoc.org.il 20160301 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   208
            changed:      domain-registrar AT isoc.org.il 20160301 (Changed)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   209
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   210
            person:       Arik Baratz
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   211
            address:      PO Box 7775 PMB 8452
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   212
            address:      San Francisco, CA
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   213
            address:      94120
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   214
            address:      USA
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   215
            phone:        +1 650 9635533
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   216
            e-mail:       hostmaster AT arik.baratz.org
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   217
            nic-hdl:      LD-AB16063-IL
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   218
            changed:      Managing Registrar 20070514
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   219
            changed:      Managing Registrar 20081002
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   220
            changed:      Managing Registrar 20081221
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   221
            changed:      Managing Registrar 20081221
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   222
            changed:      Managing Registrar 20090502
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   223
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   224
            registrar name: LiveDns Ltd
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   225
            registrar info: http://domains.livedns.co.il
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   226
        """
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   227
        expected_results = {
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   228
            "updated_date": None,
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   229
            "registrant_name": "Arik Baratz",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   230
            "fax": None,
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   231
            "dnssec": "unsigned",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   232
            "expiration_date": "2018-05-10 00:00:00",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   233
            "domain_name": "python.org.il",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   234
            "creation_date": None,
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   235
            "phone": ['+1 650 6441973', '+1 650 9635533'],
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   236
            "status": "Transfer Locked",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   237
            "emails": "hostmaster@arik.baratz.org",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   238
            "name_servers": ["dns1.zoneedit.com", "dns2.zoneedit.com", "dns3.zoneedit.com"],
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   239
            "registrar": "LiveDns Ltd",
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   240
            "referral_url": "http://domains.livedns.co.il"
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   241
        }
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   242
        self._parse_and_compare('python.org.il', data, expected_results)
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   243
156
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   244
    def test_ie_parse(self):
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   245
        data = """
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   246
        domain:       rte.ie
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   247
        descr:        RTE Commercial Enterprises Limited
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   248
        descr:        Body Corporate (Ltd,PLC,Company)
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   249
        descr:        Corporate Name
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   250
        admin-c:      AWB910-IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   251
        admin-c:      JM474-IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   252
        tech-c:       JM474-IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   253
        registration: 11-February-2000
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   254
        renewal:      31-March-2024
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   255
        holder-type:  Billable
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   256
        locked:       NO
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   257
        ren-status:   Active
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   258
        in-zone:      1
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   259
        nserver:      ns1.rte.ie 162.159.0.73 2400:cb00:2049:1::a29f:49
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   260
        nserver:      ns2.rte.ie 162.159.1.73 2400:cb00:2049:1::a29f:149
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   261
        nserver:      ns3.rte.ie 162.159.2.27 2400:cb00:2049:1::a29f:21b
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   262
        nserver:      ns4.rte.ie 162.159.3.18 2400:cb00:2049:1::a29f:312
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   263
        source:       IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   264
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   265
        person:       Michael Kennedy
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   266
        nic-hdl:      AWB910-IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   267
        source:       IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   268
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   269
        person:       John Moylan
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   270
        nic-hdl:      JM474-IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   271
        source:       IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   272
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   273
        person:       John Moylan
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   274
        nic-hdl:      JM474-IEDR
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   275
        source:       IEDR"""
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   276
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   277
        expected_results = {
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   278
            "domain_name": "rte.ie",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   279
            "description": [
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   280
                "RTE Commercial Enterprises Limited",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   281
                "Body Corporate (Ltd,PLC,Company)",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   282
                "Corporate Name"
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   283
            ],
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   284
            "source": "IEDR",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   285
            "creation_date": "2000-02-11 00:00:00",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   286
            "expiration_date": "2024-03-31 00:00:00",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   287
            "name_servers": [
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   288
                "ns1.rte.ie 162.159.0.73 2400:cb00:2049:1::a29f:49",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   289
                "ns2.rte.ie 162.159.1.73 2400:cb00:2049:1::a29f:149",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   290
                "ns3.rte.ie 162.159.2.27 2400:cb00:2049:1::a29f:21b",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   291
                "ns4.rte.ie 162.159.3.18 2400:cb00:2049:1::a29f:312"
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   292
            ],
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   293
            "status": "Active",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   294
            "admin_id": [
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   295
                "AWB910-IEDR",
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   296
                "JM474-IEDR"
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   297
            ],
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   298
            "tech_id": "JM474-IEDR"
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   299
        }
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   300
        self._parse_and_compare('rte.ie', data, expected_results)
9437303d43e8 Add handling of .ie domains
Vanush Paturyan <ektich@gmail.com>
parents: 135
diff changeset
   301
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   302
    def _parse_and_compare(self, domain_name, data, expected_results):
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   303
        results = WhoisEntry.load(domain_name, data)
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   304
        fail = 0
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   305
        total = 0
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   306
        # Compare each key
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   307
        for key in expected_results:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   308
            total += 1
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   309
            result = results.get(key)
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   310
            if isinstance(result, datetime.datetime):
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   311
                result = str(result)
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   312
            expected = expected_results.get(key)
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   313
            if expected != result:
135
808c8bc803f5 Added support for .il domains
ishirav
parents: 102
diff changeset
   314
                print("%s \t(%s):\t %s != %s" % (domain_name, key, result, expected))
102
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   315
                fail += 1
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   316
        if fail:
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   317
            self.fail("%d/%d sample whois attributes were not parsed properly!"
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   318
                      % (fail, total))
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   319
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   320
e8cb8d1367c0 Add more support for .ca domains parse dates, names, and emails correctly
Brian Murphy <brian.p.murphy@gmail.com>
parents: 97
diff changeset
   321
12
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
   322
if __name__ == '__main__':
c57439b500cb fixed test cases
Richard Baron Penman
parents: 0
diff changeset
   323
    unittest.main()