Skip to content

Commit fa84240

Browse files
committed
`Fixing issue #148.
1 parent f640385 commit fa84240

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
4.5.1 -- 8/30/2016:
2+
* Resolved issue #148:
3+
https://github.com/googleads/googleads-python-lib/issues/148
4+
15
4.5.0 -- 8/26/2016
26
* AdWordsClient's initializer no longer requires the user_agent field. This
37
field is also now validated to ensure that it only contains ASCII characters.

googleads/adwords.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ class AdWordsClient(object):
215215

216216
# The key in the storage yaml which contains AdWords data.
217217
_YAML_KEY = 'adwords'
218-
# A list of values which must be provided to use AdWords.
219-
_REQUIRED_INIT_VALUES = ('developer_token')
220-
# A list of values which may optionally be provided when using AdWords.
218+
# A tuple containing values which must be provided to use AdWords.
219+
_REQUIRED_INIT_VALUES = ('developer_token',)
220+
# A tuple containing values which may optionally be provided when using
221+
# AdWords.
221222
_OPTIONAL_INIT_VALUES = (
222223
'validate_only', 'partial_failure', 'client_customer_id', 'user_agent',
223224
'report_downloader_headers')

googleads/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
pass
4444

4545

46-
VERSION = '4.5.0'
46+
VERSION = '4.5.1'
4747
_COMMON_LIB_SIG = 'googleads/%s' % VERSION
4848
_HTTP_PROXY_YAML_KEY = 'http_proxy'
4949
_HTTPS_PROXY_YAML_KEY = 'https_proxy'

tests/adwords_test.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class AdWordsClientTest(unittest.TestCase):
252252
"""Tests for the googleads.adwords.AdWordsClient class."""
253253

254254
def setUp(self):
255+
self.load_from_storage_path = os.path.join(
256+
os.path.dirname(__file__), 'test_data/adwords_googleads.yaml')
255257
self.https_proxy_host = 'myproxy'
256258
self.https_proxy_port = 443
257259
self.proxy_config = GetProxyConfig(https_host=self.https_proxy_host,
@@ -264,13 +266,9 @@ def setUp(self):
264266
self.adwords_client, CURRENT_VERSION)
265267

266268
def testLoadFromStorage(self):
267-
with mock.patch('googleads.common.LoadFromStorage') as mock_load:
268-
mock_load.return_value = {
269-
'developer_token': 'abcdEFghIjkLMOpqRs',
270-
'oauth2_client': mock.Mock(),
271-
'user_agent': 'unit testing'
272-
}
273-
self.assertIsInstance(googleads.adwords.AdWordsClient.LoadFromStorage(),
269+
with mock.patch('googleads.oauth2.GoogleRefreshTokenClient.Refresh'):
270+
self.assertIsInstance(googleads.adwords.AdWordsClient.LoadFromStorage(
271+
path=self.load_from_storage_path),
274272
googleads.adwords.AdWordsClient)
275273

276274
def testLoadFromStorageWithNonASCIIUserAgent(self):
@@ -446,30 +444,32 @@ def setUp(self):
446444
def setUpClass(cls):
447445
test_dir = os.path.dirname(__file__)
448446
with open(os.path.join(
449-
test_dir, 'data/batch_job_util_budget_template.txt')) as handler:
447+
test_dir, 'test_data/batch_job_util_budget_template.txt')) as handler:
450448
cls.BUDGET_TEMPLATE = handler.read()
451449
with open(os.path.join(
452450
test_dir,
453-
'data/batch_job_util_campaign_criterion_template.txt')) as handler:
451+
'test_data/batch_job_util_campaign_criterion_template.txt')) as handler:
454452
cls.CAMPAIGN_CRITERION_TEMPLATE = handler.read()
455453
with open(os.path.join(
456454
test_dir,
457-
'data/batch_job_util_campaign_label_template.txt')) as handler:
455+
'test_data/batch_job_util_campaign_label_template.txt')) as handler:
458456
cls.CAMPAIGN_LABEL_TEMPLATE = handler.read()
459457
with open(os.path.join(
460-
test_dir, 'data/batch_job_util_invalid_request.txt')) as handler:
458+
test_dir, 'test_data/batch_job_util_invalid_request.txt')) as handler:
461459
cls.INVALID_API_REQUEST = handler.read()
462460
with open(os.path.join(
463-
test_dir, 'data/batch_job_util_not_request.txt')) as handler:
461+
test_dir, 'test_data/batch_job_util_not_request.txt')) as handler:
464462
cls.NOT_API_REQUEST = handler.read()
465463
with open(os.path.join(
466-
test_dir, 'data/batch_job_util_raw_request_template.txt')) as handler:
464+
test_dir, 'test_data/batch_job_util_raw_request_template.txt')
465+
) as handler:
467466
cls.RAW_API_REQUEST_TEMPLATE = handler.read()
468467
with open(os.path.join(
469-
test_dir, 'data/batch_job_util_operations_template.txt')) as handler:
468+
test_dir, 'test_data/batch_job_util_operations_template.txt')
469+
) as handler:
470470
cls.OPERATIONS_TEMPLATE = handler.read()
471471
with open(os.path.join(
472-
test_dir, 'data/batch_job_util_upload_template.txt')) as handler:
472+
test_dir, 'test_data/batch_job_util_upload_template.txt')) as handler:
473473
cls.UPLOAD_OPERATIONS_TEMPLATE = handler.read()
474474

475475
def ExpandOperandTemplate(self, operation_type, operand):
@@ -1254,7 +1254,7 @@ def setUp(self):
12541254
def setUpClass(cls):
12551255
test_dir = os.path.dirname(__file__)
12561256
with open(os.path.join(
1257-
test_dir, 'data/batch_job_util_response_template.txt')) as handler:
1257+
test_dir, 'test_data/batch_job_util_response_template.txt')) as handler:
12581258
cls.API_RESPONSE_XML_TEMPLATE = handler.read()
12591259

12601260
def testParseResponse(self):

0 commit comments

Comments
 (0)