-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_lead.py
73 lines (61 loc) · 2.07 KB
/
test_lead.py
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
import unittest
from unittest import skip
from unittest.mock import patch
from amocrm.exceptions import MissingArgument
from amocrm.entities import Lead
from .base_mocksettings import BaseMockSettingsTest
class TestLead(BaseMockSettingsTest):
def test_Lead_todict_returns_dict(self):
amolead = Lead(
name=self.name,
status_id=123,
)
d = amolead.todict()
self.assertIsNotNone(d)
self.assertIsInstance(d, dict)
def test_Lead_raises_on_empty_name(self):
with self.assertRaises(MissingArgument):
Lead(status_id=123)
def test_Lead_raises_on_empty_status_id(self):
with self.assertRaises(MissingArgument):
Lead(name=self.name)
def test_Lead_builds_correct_dict(self):
name = 'Vasya'
status_id = 123
amolead = Lead(
name=name,
status_id=status_id,
)
d = amolead.todict()
self.assertEqual(d, {
"request": {
"leads": {
"add": [{
"name": name,
"status_id": status_id,
# "status_id":"9211617", # главная воронка
# "date_create":1298904164,
# "last_modified":1298904164,
# "price":300000,
# "responsible_user_id":215302,
# "tags": "Заявка,beta",
# "custom_fields":[{
# "id":461512,
# "values":[{
# "value": 9776621,
# "enum": "HOME"
# }]
# }]
}]
}
}
})
def test_Lead_is_json_serializable(self):
amolead = Lead(
name=self.name,
status_id=123
)
try:
str(amolead)
except TypeError as e:
self.fail('Lead is not JSON serializable!')