aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/test/unit/test_unassigned.py
blob: 08ab943bb75d84bb958494e4205549836f59ba0f (about) (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import json

from sendgrid.helpers.endpoints.ip.unassigned import unassigned

ret_json = '''[ {
	"ip": "167.89.21.3",
        "pools": [
		"pool1",
	"pool2"
	],
        "whitelabeled": false,
        "start_date": 1409616000,
        "subusers": [
          "tim@sendgrid.net"
        ],
        "warmup": false,
        "assigned_at": 1482883200
      },
      {
        "ip": "192.168.1.1",
        "pools": [
          "pool1",
          "pool2"
        ],
        "whitelabeled": false,
        "start_date": 1409616000,
        "subusers": [
          "tim@sendgrid.net"
        ],
        "warmup": false,
        "assigned_at": 1482883200
      },
      {
        "ip": "208.115.214.22",
        "pools": [],
        "whitelabeled": true,
        "rdns": "o1.email.burgermail.com",
        "start_date": 1409616000,
        "subusers": [],
        "warmup": false,
        "assigned_at": 1482883200
      },
      {
        "ip": "208.115.214.23",
        "pools": [],
        "whitelabeled": true,
        "rdns": "o1.email.burgermail.com",
        "start_date": 1409616000,
        "subusers": [],
        "warmup": false,
        "assigned_at": 1482883200

      } ]
      '''


def get_all_ip():
    ret_val = json.loads(ret_json)
    return ret_val


def make_data():
    data = set()
    data.add("208.115.214.23")
    data.add("208.115.214.22")
    return data


def test_unassigned_ip_json():
    data = make_data()

    as_json = True
    calculated = unassigned(get_all_ip(), as_json=as_json)
    calculated = json.loads(calculated)

    for item in calculated:
        assert item["ip"] in data


def test_unassigned_ip_obj():
    data = make_data()

    as_json = False
    calculated = unassigned(get_all_ip(), as_json=as_json)

    for item in calculated:
        assert item["ip"] in data


def test_unassigned_baddata():
    as_json = False
    calculated = unassigned(dict(), as_json=as_json)
    assert calculated == []