From 0f580086d13294326cab833f0e0b04d66b07750d Mon Sep 17 00:00:00 2001 From: Matin Tamizi Date: Wed, 6 Mar 2019 11:51:28 -0600 Subject: [PATCH] use black --- Makefile | 1 + botmaker/client.py | 20 +++++++------------- setup.py | 2 +- tests/conftest.py | 2 +- tests/test_template_messages.py | 14 ++++++++++---- tests/test_whatsapp.py | 3 ++- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 248ab58..7baacac 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ test: clean install-test lint python setup.py test polish: + black -S -l 79 **/*.py isort -rc --atomic . lint: diff --git a/botmaker/client.py b/botmaker/client.py index fabb0fa..6ff13dd 100644 --- a/botmaker/client.py +++ b/botmaker/client.py @@ -24,14 +24,13 @@ def get(self, endpoint: str, **kwargs) -> dict: def post(self, endpoint: str, data: dict, **kwargs) -> dict: return self.request('post', endpoint, data, **kwargs) - def request(self, - method: str, - endpoint: str, - data: dict, - **kwargs) -> dict: + def request( + self, method: str, endpoint: str, data: dict, **kwargs + ) -> dict: url = self.BASE_URL + endpoint response = requests.request( - method, url, headers=self.headers, json=data, **kwargs) + method, url, headers=self.headers, json=data, **kwargs + ) self._check_response(response) return response.json() @@ -47,19 +46,14 @@ def _check_response(response): response.raise_for_status() def check_whatsapp_contact( - self, - channel: str, - phone_number: str + self, channel: str, phone_number: str ) -> Optional[str]: """ Based on https://botmakeradmin.github.io/docs/es/#/messages-api?id=chequear-validez-de-n%C3%BAmeros-de-contactos-de-whatsapp """ channel = sanitize_phone_number(channel) - data = dict( - chatChannelNumber=channel, - contacts=[phone_number] - ) + data = dict(chatChannelNumber=channel, contacts=[phone_number]) resp = self.post('/customer/checkWhatsAppContact', data) try: result = resp['result'] diff --git a/setup.py b/setup.py index 30d61fe..b12fecc 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ ] test_requires = ['pytest', 'pytest-vcr', 'pycodestyle', 'pytest-cov', - 'isort[pipfile]'] + 'black', 'isort[pipfile]'] with open('README.md', 'r') as f: long_description = f.read() diff --git a/tests/conftest.py b/tests/conftest.py index 213a7be..fa3c5d8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,7 +11,7 @@ def vcr_config(): config['filter_post_data_parameters'] = [ ('chatChannelNumber', '5215500000000'), ('platformContactId', '5215522222222'), - ('contacts', ['+55 1 55 1234 5678']) + ('contacts', ['+55 1 55 1234 5678']), ] return config diff --git a/tests/test_template_messages.py b/tests/test_template_messages.py index 20a3a08..99170ce 100644 --- a/tests/test_template_messages.py +++ b/tests/test_template_messages.py @@ -6,8 +6,11 @@ @pytest.mark.vcr def test_template_message(client): tm = client.template_messages.create( - '5215500000000', '+55 1 55 1234 5678', 'phone_number_verification', - codigo_de_6_digitos='123456') + '5215500000000', + '+55 1 55 1234 5678', + 'phone_number_verification', + codigo_de_6_digitos='123456', + ) assert tm.id assert tm == tm assert repr(tm) @@ -18,5 +21,8 @@ def test_template_message(client): def test_invalid_whatsapp_number(client): with pytest.raises(InvalidPhoneNumber): client.template_messages.create( - '5215500000000', '123', 'phone_number_verification', - codigo_de_6_digitos='123456') + '5215500000000', + '123', + 'phone_number_verification', + codigo_de_6_digitos='123456', + ) diff --git a/tests/test_whatsapp.py b/tests/test_whatsapp.py index e49a2f2..25645a2 100644 --- a/tests/test_whatsapp.py +++ b/tests/test_whatsapp.py @@ -8,7 +8,8 @@ def test_check_whatsapp_contact(client): phone_number = '+55 1 55 1234 5678' checked_contact = '5515512345678' assert checked_contact == client.check_whatsapp_contact( - '5215500000000', phone_number) + '5215500000000', phone_number + ) @pytest.mark.vcr