Skip to content

Commit

Permalink
use black
Browse files Browse the repository at this point in the history
  • Loading branch information
matin committed Mar 6, 2019
1 parent 302f242 commit 0f58008
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ test: clean install-test lint
python setup.py test

polish:
black -S -l 79 **/*.py
isort -rc --atomic .

lint:
Expand Down
20 changes: 7 additions & 13 deletions botmaker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions tests/test_template_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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',
)
3 changes: 2 additions & 1 deletion tests/test_whatsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f58008

Please sign in to comment.