From 6c3260b6ee8cffd2ba9a46cae41bc493dafcb3be Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Fri, 6 Oct 2017 15:23:44 +0200 Subject: [PATCH] Move credentials tests to GoogleMapsClientFactoryTestCase --- .../test/test_google_client_factory.py | 11 +++++++++++ .../test/test_googlegeocoder.py | 18 +----------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/server/lib/python/cartodb_services/test/test_google_client_factory.py b/server/lib/python/cartodb_services/test/test_google_client_factory.py index b5b3121..f245925 100644 --- a/server/lib/python/cartodb_services/test/test_google_client_factory.py +++ b/server/lib/python/cartodb_services/test/test_google_client_factory.py @@ -5,6 +5,7 @@ import unittest import base64 from cartodb_services.google.client_factory import GoogleMapsClientFactory +from cartodb_services.google.exceptions import InvalidGoogleCredentials class GoogleMapsClientFactoryTestCase(unittest.TestCase): @@ -45,3 +46,13 @@ class GoogleMapsClientFactoryTestCase(unittest.TestCase): client1 = GoogleMapsClientFactory.get(id1, key) client2 = GoogleMapsClientFactory.get(id2, key) self.assertNotEqual(client1, client2) + + def test_invalid_credentials(self): + with self.assertRaises(InvalidGoogleCredentials): + GoogleMapsClientFactory.get('dummy_client_id', 'lalala') + + def test_credentials_with_dashes_can_be_valid(self): + GoogleMapsClientFactory.get('yet_another_dummy_client_id', 'Ola-k-ase---') + + def test_credentials_with_underscores_can_be_valid(self): + GoogleMapsClientFactory.get('yet_another_dummy_client_id', 'Ola_k_ase___') diff --git a/server/lib/python/cartodb_services/test/test_googlegeocoder.py b/server/lib/python/cartodb_services/test/test_googlegeocoder.py index f2b7a5e..ecbaa7b 100644 --- a/server/lib/python/cartodb_services/test/test_googlegeocoder.py +++ b/server/lib/python/cartodb_services/test/test_googlegeocoder.py @@ -6,7 +6,7 @@ import requests_mock from mock import Mock from cartodb_services.google import GoogleMapsGeocoder -from cartodb_services.google.exceptions import MalformedResult, InvalidGoogleCredentials +from cartodb_services.google.exceptions import MalformedResult requests_mock.Mocker.TEST_PREFIX = 'test_' @@ -118,19 +118,3 @@ class GoogleGeocoderTestCase(unittest.TestCase): searchtext='Calle Eloy Gonzalo 27', city='Madrid', country='EspaƱa') - - def test_invalid_credentials(self, req_mock): - with self.assertRaises(InvalidGoogleCredentials): - GoogleMapsGeocoder('dummy_client_id', - 'lalala', - None) - - def test_credentials_with_dashes_can_be_valid(self, req_mock): - GoogleMapsGeocoder('yet_another_dummy_client_id', - 'Ola-k-ase---', - None) - - def test_credentials_with_underscores_can_be_valid(self, req_mock): - GoogleMapsGeocoder('yet_another_dummy_client_id', - 'Ola_k_ase___', - None)