Skip to content

Commit 0595f4e

Browse files
hassansinpkopac
authored andcommitted
Remove schema from Stripe & Clearbit attributes [ch426] (#20)
* Removed schema from Stripe & Clearbit attributes [ch426] * Version bumped to 1.1.8 [ch426] * Fixing travis build for 3.3 [ch426] * Removed 3.3 [ch426]
1 parent 585ecf3 commit 0595f4e

File tree

5 files changed

+95
-92
lines changed

5 files changed

+95
-92
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ language: python
22

33
python:
44
- "2.7"
5-
- "3.3"
65
- "3.4"
76
- "3.5"
87
- "3.6"

chartmogul/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"""
3030

3131
__title__ = 'chartmogul'
32-
__version__ = '1.1.7'
32+
__version__ = '1.1.8'
3333
__build__ = 0x000000
3434
__author__ = 'ChartMogul Ltd'
3535
__license__ = 'MIT'

chartmogul/api/attributes.py

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,6 @@
11
from marshmallow import Schema, fields, post_load
22
from ..resource import Resource, DataObject
33

4-
5-
class Stripe(DataObject):
6-
class _Schema(Schema):
7-
uid = fields.Int()
8-
coupon = fields.Boolean()
9-
10-
@post_load
11-
def make(self, data):
12-
return Stripe(**data)
13-
14-
15-
class Name(DataObject):
16-
class _Schema(Schema):
17-
fullName = fields.String()
18-
19-
@post_load
20-
def make(self, data):
21-
return Name(**data)
22-
23-
24-
class Employment(DataObject):
25-
class _Schema(Schema):
26-
name = fields.String()
27-
28-
@post_load
29-
def make(self, data):
30-
return Employment(**data)
31-
32-
33-
class Person(DataObject):
34-
class _Schema(Schema):
35-
name = fields.Nested(Name._Schema)
36-
employment = fields.Nested(Employment._Schema)
37-
38-
@post_load
39-
def make(self, data):
40-
return Person(**data)
41-
42-
43-
class Company(DataObject):
44-
class _Schema(Schema):
45-
name = fields.String()
46-
legalName = fields.String()
47-
domain = fields.String()
48-
url = fields.String()
49-
category = fields.Dict()
50-
metrics = fields.Dict()
51-
52-
@post_load
53-
def make(self, data):
54-
return Company(**data)
55-
56-
57-
class Clearbit(DataObject):
58-
class _Schema(Schema):
59-
company = fields.Nested(Company._Schema)
60-
person = fields.Nested(Person._Schema)
61-
62-
@post_load
63-
def make(self, data):
64-
return Clearbit(**data)
65-
66-
674
class Attributes(Resource):
685
"""
696
https://dev.chartmogul.com/v1.0/reference#customer-attributes
@@ -72,8 +9,8 @@ class Attributes(Resource):
729

7310
class _Schema(Schema):
7411
tags = fields.List(fields.String())
75-
stripe = fields.Nested(Stripe._Schema)
76-
clearbit = fields.Nested(Clearbit._Schema)
12+
stripe = fields.Dict()
13+
clearbit = fields.Dict()
7714
custom = fields.Dict()
7815

7916
@post_load

chartmogul/api/customer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from marshmallow import Schema, fields, post_load
99
from ..resource import Resource, DataObject, _add_method
1010
from collections import namedtuple
11-
from .attributes import Stripe, Name, Employment, Person, Company, Clearbit, Attributes
11+
from .attributes import Attributes
1212

1313

1414
class Address(DataObject):

test/api/test_customer.py

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import unittest
22
from chartmogul import Customer, Config
3-
from chartmogul.api.customer import Attributes, Stripe, Clearbit,\
4-
Company, Person, Name, Employment, Address
3+
from chartmogul.api.customer import Attributes, Address
54
from datetime import datetime
65
import requests_mock
76

@@ -112,39 +111,39 @@
112111
zip="0185128",
113112
attributes=Attributes(
114113
tags=["engage", "unit loss", "discountable"],
115-
stripe=Stripe(
116-
uid=7,
117-
coupon=True
118-
),
119-
clearbit=Clearbit(
120-
company=Company(
121-
name="Example Company",
122-
legalName="Example Company Inc.",
123-
domain="examplecompany.com",
124-
url="http://examplecompany.com",
125-
category={
114+
stripe={
115+
"uid": 7,
116+
"coupon": True
117+
},
118+
clearbit={
119+
"company": {
120+
"name": "Example Company",
121+
"legalName": "Example Company Inc.",
122+
"domain": "examplecompany.com",
123+
"url": "http://examplecompany.com",
124+
"category": {
126125
"sector": "Information Technology",
127126
"industryGroup": "Software and Services",
128127
"industry": "Software",
129128
"subIndustry": "Application Software"
130129
},
131-
metrics={
130+
"metrics": {
132131
"alexaGlobalRank": 2319,
133132
"googleRank": 7,
134133
"employees": 1000,
135134
"marketCap": None,
136135
"raised": 1502450000
137136
},
138-
),
139-
person=Person(
140-
name=Name(
141-
fullName="Bob Kramer"
142-
),
143-
employment=Employment(
144-
name="Example Company"
145-
)
146-
)
147-
),
137+
},
138+
"person": {
139+
"name": {
140+
"fullName": "Bob Kramer"
141+
},
142+
"employment": {
143+
"name": "Example Company"
144+
}
145+
}
146+
},
148147
custom={
149148
"CAC": 213,
150149
"utmCampaign": "social media 1",
@@ -183,6 +182,39 @@
183182
"zip": "0185128",
184183
"attributes": {
185184
"tags": ["engage", "unit loss", "discountable"],
185+
"stripe":{
186+
"uid": 7,
187+
"coupon": True
188+
},
189+
"clearbit": {
190+
"company": {
191+
"name": "Example Company",
192+
"legalName": "Example Company Inc.",
193+
"domain": "examplecompany.com",
194+
"url": "http://examplecompany.com",
195+
"category": {
196+
"sector": "Information Technology",
197+
"industryGroup": "Software and Services",
198+
"industry": "Software",
199+
"subIndustry": "Application Software"
200+
},
201+
"metrics": {
202+
"raised": 1502450000,
203+
"employees": 1000,
204+
"googleRank": 7,
205+
"alexaGlobalRank": 2319,
206+
"marketCap": None
207+
},
208+
},
209+
"person": {
210+
"name": {
211+
"fullName": "Bob Kramer"
212+
},
213+
"employment": {
214+
"name": "Example Company"
215+
}
216+
}
217+
},
186218
"custom": [
187219
{'key': 'CAC', 'type': 'Integer', 'value': 213},
188220
{"key": "utmCampaign", "value": "social media 1", "type": "String"},
@@ -195,6 +227,39 @@
195227

196228
sentCreateExpected = {
197229
'attributes': {
230+
"stripe":{
231+
"uid": 7,
232+
"coupon": True
233+
},
234+
"clearbit": {
235+
"company": {
236+
"name": "Example Company",
237+
"legalName": "Example Company Inc.",
238+
"domain": "examplecompany.com",
239+
"url": "http://examplecompany.com",
240+
"category": {
241+
"sector": "Information Technology",
242+
"industryGroup": "Software and Services",
243+
"industry": "Software",
244+
"subIndustry": "Application Software"
245+
},
246+
"metrics": {
247+
"raised": 1502450000,
248+
"employees": 1000,
249+
"googleRank": 7,
250+
"alexaGlobalRank": 2319,
251+
"marketCap": None
252+
},
253+
},
254+
"person": {
255+
"name": {
256+
"fullName": "Bob Kramer"
257+
},
258+
"employment": {
259+
"name": "Example Company"
260+
}
261+
}
262+
},
198263
'custom': [
199264
{'key': 'CAC', 'type': 'Integer', 'value': 213},
200265
{"key": "utmCampaign", "value": "social media 1", "type": "String"},
@@ -254,6 +319,8 @@ def test_all(self, mock_requests):
254319
# self.assertEqual(str(customers), str(expected))
255320
# => check only first level fields are OK
256321
self.assertEqual(sorted(dir(customers)), sorted(dir(expected)))
322+
self.assertEqual(sorted(customers.entries[0].attributes.stripe), sorted(expected.entries[0].attributes.stripe))
323+
self.assertEqual(sorted(customers.entries[0].attributes.clearbit), sorted(expected.entries[0].attributes.clearbit))
257324
self.assertTrue(isinstance(customers.entries[0], Customer))
258325

259326
@requests_mock.mock()

0 commit comments

Comments
 (0)