forked from clearbit/clearbit-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
128 lines (103 loc) · 6.48 KB
/
tests.py
File metadata and controls
128 lines (103 loc) · 6.48 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import sys
import unittest
if sys.version_info > (3, 3):
from unittest.mock import patch
else:
from mock import patch
import clearbit
from clearbit import *
clearbit.key = 'k'
class TestResource(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_clearbit_key(self, requests):
Resource.get('http://x.clearbit.com/test', key='mykey')
requests.get.assert_called_with('http://x.clearbit.com/test', params={}, auth=('mykey', ''))
@patch('clearbit.resource.requests')
def test_stream(self, requests):
Resource.get('http://x.clearbit.com/test', stream=True)
requests.get.assert_called_with('http://x-stream.clearbit.com/test', params={}, auth=('k', ''))
class TestPerson(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_webhook_url(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/people/find', params={'email': '[email protected]', 'webhook_url': 'http://webhook.com/webhook'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_webhook_id(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/people/find', params={'email': '[email protected]', 'webhook_id': 'myid'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_subscribe(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/people/find', params={'email': '[email protected]', 'subscribe': True}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_endpoint(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/people/find', params={'email': '[email protected]'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_find_by_id(self, requests):
Person.find(id='theid')
requests.get.assert_called_with('https://person.clearbit.com/v2/people/theid', params={}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_flag(self, requests):
person = Person(id='theid')
person.flag(given_name='John')
requests.post.assert_called_with('https://person.clearbit.com/v2/people/theid/flag', json={'given_name': 'John'}, auth=('k', ''))
class TestCompany(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_webhook_url(self, requests):
Company.find(domain='example.com', webhook_url='http://webhook.com/webhook')
requests.get.assert_called_with('https://company.clearbit.com/v2/companies/find', params={'domain': 'example.com', 'webhook_url': 'http://webhook.com/webhook'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_webhook_id(self, requests):
Company.find(domain='example.com', webhook_id='myid')
requests.get.assert_called_with('https://company.clearbit.com/v2/companies/find', params={'domain': 'example.com', 'webhook_id': 'myid'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_subscribe(self, requests):
Company.find(domain='example.com', subscribe=True)
requests.get.assert_called_with('https://company.clearbit.com/v2/companies/find', params={'domain': 'example.com', 'subscribe': True}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_endpoint(self, requests):
Company.find(domain='example.com')
requests.get.assert_called_with('https://company.clearbit.com/v2/companies/find', params={'domain': 'example.com'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_find_by_id(self, requests):
Company.find(id='theid')
requests.get.assert_called_with('https://company.clearbit.com/v2/companies/theid', params={}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_flag(self, requests):
company = Company(id='theid')
company.flag(name='ACME Inc')
requests.post.assert_called_with('https://company.clearbit.com/v2/companies/theid/flag', json={'name': 'ACME Inc'}, auth=('k', ''))
class TestEnrichment(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_webhook_url(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/combined/find', params={'email': '[email protected]', 'webhook_url': 'http://webhook.com/webhook'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_webhook_id(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/combined/find', params={'email': '[email protected]', 'webhook_id': 'myid'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_subscribe(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/combined/find', params={'email': '[email protected]', 'subscribe': True}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_endpoint(self, requests):
requests.get.assert_called_with('https://person.clearbit.com/v2/combined/find', params={'email': '[email protected]'}, auth=('k', ''))
class TestProspector(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_search(self, requests):
Prospector.search(domain='example.com')
requests.get.assert_called_with('https://prospector.clearbit.com/v1/people/search', params={'domain': 'example.com'}, auth=('k', ''))
@patch('clearbit.resource.requests')
def test_search_titles(self, requests):
Prospector.search(domain='example.com', titles=['Sales Director', 'Marketing Director'])
requests.get.assert_called_with('https://prospector.clearbit.com/v1/people/search', params={'domain': 'example.com', 'titles[]': ['Sales Director', 'Marketing Director']}, auth=('k', ''))
class TestNameToDomain(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_find(self, requests):
NameToDomain.find(name='Uber')
requests.get.assert_called_with('https://company.clearbit.com/v1/domains/find', params={'name': 'Uber'}, auth=('k', ''))
if __name__ == '__main__':
unittest.main()