Skip to content

Commit 04c7301

Browse files
author
Rasmus Lager
committed
static methods and removed unused import
1 parent 49c6bcf commit 04c7301

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

ganapi/contact.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class Contact(Entity):
1515
updated = None
1616
created = None
1717

18-
def hash_in_contacts_lists(self, hash, list):
18+
@staticmethod
19+
def hash_in_contacts_lists(hash, list):
1920

2021
if any(sub['hash'] == hash for sub in list):
2122
return True

ganapi/entity_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import urlparse
55
import math
66

7+
78
class EntityManager(object):
89
"""
910
Base entity manager.
@@ -166,7 +167,7 @@ def overwrite(self, entity):
166167
"""
167168
return self.save(entity, True)
168169

169-
def query(self, filters=dict(), as_json=False):
170+
def query(self, filters=None, as_json=False):
170171
"""
171172
Low level method for making search queries.
172173
@@ -179,6 +180,8 @@ def query(self, filters=dict(), as_json=False):
179180
:returns class PaginatedResultSet which can iterate over pages PaginatedResultSet.entities is the current page list of entities.
180181
:raises RequestException if there is an error from the API.
181182
"""
183+
if not filters:
184+
filters = dict()
182185
uri = u'{base_path}/?{encoded_filters}'.format(base_path=str.rstrip(self.base_path),
183186
encoded_filters=urllib.urlencode(filters))
184187
response = self.api.call('GET', uri)

ganapi/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def build_entities_list(self, results):
2929
list.append(self.manager.construct_entity(result).set_persisted())
3030
return list
3131

32-
def url_params_to_dict(self, url):
32+
@staticmethod
33+
def url_params_to_dict(url):
3334
"""
3435
:param url: url to get parameters from
3536
:return: parsed parameters as dict

ganapi/test_attribute_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from api import Api
33
from attribute import Attribute
44
from attribute_manager import AttributeManager
5-
from httmock import HTTMock, all_requests, urlmatch
5+
from httmock import HTTMock, all_requests
66
from requests import HTTPError
77

88

ganapi/test_contact.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from api import Api
2-
from contact import Contact
32
from contact_manager import ContactManager
43
from list_manager import ListManager
54
import unittest
@@ -40,8 +39,6 @@ def contact_unsubscribe_mock(self, url, request):
4039
return {'status_code': 201,
4140
'content': content}
4241

43-
44-
4542
def test_subscribe_to_list(self):
4643
new_contact = self.contact_manager.create()
4744
new_contact.email = 'tester@example.com'
@@ -56,7 +53,6 @@ def test_subscribe_to_list(self):
5653
saved_contact = new_contact.save()
5754
self.assertEqual(saved_contact.lists[0]['hash'], '2anfLVM')
5855

59-
6056
def test_unsubcribe_from_list(self):
6157
new_contact = self.contact_manager.create()
6258
new_contact.email = 'tester@example.com'

0 commit comments

Comments
 (0)