Skip to content

Commit e11ff95

Browse files
authored
Fix tests and update
Fix tests and update
2 parents 570a06c + dd05e28 commit e11ff95

File tree

13 files changed

+285
-863
lines changed

13 files changed

+285
-863
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ name: Tests
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- master
67
pull_request:
78

89
jobs:
910
LintingAndTests:
1011
runs-on: ubuntu-latest
1112

1213
steps:
13-
- uses: actions/checkout@v2
14-
- name: Set up Python
15-
uses: actions/setup-python@v1
16-
with:
17-
python-version: 3.7
18-
- name: Install dependencies
19-
run: |
20-
pip install pipenv
21-
pipenv install --dev
22-
- name: Lint with pylint
23-
run: |
24-
pipenv run pylint funcs/* app/*
25-
- name: Test with pytest
26-
run: |
27-
pipenv run python -m pytest -v
14+
- uses: actions/checkout@v2
15+
- name: Set up Python
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.9
19+
- name: Install dependencies
20+
run: |
21+
pip install pipenv
22+
pipenv install --dev
23+
- name: Lint with pylint
24+
run: |
25+
pipenv run pylint funcs/* app/*
26+
- name: Test with pytest
27+
run: |
28+
pipenv run python -m pytest -v

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*.*.*'
6+
- "*.*.*"
77

88
jobs:
9-
109
Release:
1110
runs-on: ubuntu-latest
1211

@@ -34,7 +33,7 @@ jobs:
3433
- name: Set up Python
3534
uses: actions/setup-python@v1
3635
with:
37-
python-version: 3.7
36+
python-version: 3.9
3837
- name: Install dependencies
3938
run: |
4039
pip install pipenv

Pipfile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ name = "pypi"
33
url = "https://pypi.org/simple"
44
verify_ssl = true
55

6-
[dev-packages]
7-
autopep8 = "~=1.5"
8-
pylint = "~=2.6"
9-
pylint-quotes = "~=0.2"
10-
pytest = "~=6.1"
11-
pytest-mock = "~=3.3"
12-
Faker = "~=4.9"
13-
freezegun = "~=1.0.0"
14-
rope = "~=0.18.0"
15-
166
[packages]
17-
requests = "~=2.24"
18-
pytz = ">=2020"
19-
workalendar = "~=12.1.0"
7+
requests = ">=2"
8+
pytz = ">=2021.3"
9+
workalendar = ">=16"
10+
11+
[dev-packages]
12+
autopep8 = ">=1"
13+
pylint = ">=2"
14+
pylint-quotes = ">=0.2"
15+
pytest = ">=6"
16+
pytest-mock = ">=3"
17+
Faker = ">=9"
18+
freezegun = ">=1"
19+
rope = ">=0.22"
2020

2121
[requires]
22-
python_version = "3.7"
22+
python_version = "3.9"

Pipfile.lock

Lines changed: 206 additions & 273 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ Bot do Telegram que informa os horários de saída dos ônibus da Grande Vitóri
1111
```shell
1212
# Instalando serverless
1313
# Necessário Node
14-
sudo npm install serverless -g
15-
16-
# instalando plugins
17-
npm i
14+
sudo npm install -g serverless
1815

1916
# Instalando autocomplete
2017
sls config tabcompletion install

app/contexto.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,9 @@ def is_valido(self):
6464
self.feriado is not None)
6565

6666
def __str__(self):
67-
return '''
68-
qtde_horarios: {}
69-
hora_atual: {}
70-
dia_semana: {}
71-
feriado: {}
72-
'''.format(self.qtde_horarios,
73-
self.hora_atual,
74-
self.dia_semana,
75-
self.feriado)
67+
return f'''
68+
qtde_horarios: {self.qtde_horarios}
69+
hora_atual: {self.hora_atual}
70+
dia_semana: {self.dia_semana}
71+
feriado: {self.feriado}
72+
'''

app/gvbus_proxy.py

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ def __init__(self, linha):
1414
def __set_horarios_api(self):
1515
if self.__horarios is None:
1616
try:
17-
url_horarios = '{}/{}/{}'.format(GvbusProxy.__GVBUS_URL,
18-
'buscahorarios', self.linha)
17+
url_horarios = f'{GvbusProxy.__GVBUS_URL}/buscahorarios/{self.linha}'
1918
res_horarios = requests.get(url_horarios, timeout=2)
20-
url_observacoes = '{}/{}/{}'.format(GvbusProxy.__GVBUS_URL,
21-
'BuscaHorarioObse', self.linha)
19+
url_observacoes = f'{GvbusProxy.__GVBUS_URL}/BuscaHorarioObse/{self.linha}'
2220
res_observacoes = requests.get(url_observacoes, timeout=2)
2321

2422
if res_horarios.status_code == 200 and res_observacoes.status_code == 200:
@@ -105,8 +103,8 @@ def preencher_horarios(self, item, ida=True):
105103

106104
def get_descricao_linha(self):
107105
if self.is_inexistente():
108-
return '{} - Inexistente'.format(self.linha)
109-
return '{} - {}'.format(self.linha, self.__desc_linha)
106+
return f'{self.linha} - Inexistente'
107+
return f'{self.linha} - {self.__desc_linha}'
110108

111109
def is_inexistente(self):
112110
return self.__desc_linha is None
@@ -115,64 +113,49 @@ def is_circular(self):
115113
return self.__desc_terminal_volta is None
116114

117115
def get_str_horario_contexto(self, contexto):
118-
str_horarios = '''
119-
*\U0001F68C {}*
120-
\U0001F4CD {}
121-
{}
122-
{}
123-
{}
124-
'''.format(self.get_descricao_linha(),
125-
self.__desc_terminal_ida,
126-
Horarios.get_desc_dia_contexto(
127-
'Dia útil', contexto.is_dia_util(), self.__horarios_dia_util_ida, contexto),
128-
Horarios.get_desc_dia_contexto(
129-
'Sábado', contexto.is_sabado(), self.__horarios_sabado_ida, contexto),
130-
Horarios.get_desc_dia_contexto(
131-
'Dom/Feriado', contexto.is_domingo(), self.__horarios_domingo_ida, contexto))
116+
str_horarios = f'''
117+
*\U0001F68C {self.get_descricao_linha()}*
118+
\U0001F4CD {self.__desc_terminal_ida}
119+
{Horarios.get_desc_dia_contexto(
120+
'Dia útil', contexto.is_dia_util(), self.__horarios_dia_util_ida, contexto)}
121+
{Horarios.get_desc_dia_contexto(
122+
'Sábado', contexto.is_sabado(), self.__horarios_sabado_ida, contexto)}
123+
{Horarios.get_desc_dia_contexto(
124+
'Dom/Feriado', contexto.is_domingo(), self.__horarios_domingo_ida, contexto)}
125+
'''
132126

133127
if not self.is_circular():
134-
str_horarios += '''
135-
\U0001F4CD {}
136-
{}
137-
{}
138-
{}
139-
'''.format(self.__desc_terminal_volta,
140-
Horarios.get_desc_dia_contexto(
128+
str_horarios += f'''
129+
\U0001F4CD {self.__desc_terminal_volta}
130+
{Horarios.get_desc_dia_contexto(
141131
'Dia útil', contexto.is_dia_util(), self.__horarios_dia_util_volta,
142-
contexto),
143-
Horarios.get_desc_dia_contexto(
132+
contexto)}
133+
{Horarios.get_desc_dia_contexto(
144134
'Sábado', contexto.is_sabado(), self.__horarios_sabado_volta,
145-
contexto),
146-
Horarios.get_desc_dia_contexto(
135+
contexto)}
136+
{Horarios.get_desc_dia_contexto(
147137
'Dom/Feriado', contexto.is_domingo(), self.__horarios_domingo_volta,
148-
contexto))
138+
contexto)}
139+
'''
149140

150141
if contexto.orientacoes.intersection(self.__observacoes):
151142
str_horarios += '''
152143
\U00002757 OBSERVAÇÃO
153144
'''
154145
for item in sorted(contexto.orientacoes.intersection(self.__observacoes)):
155-
str_horarios += '''{}: {}
156-
'''.format(item, self.__observacoes[item])
146+
str_horarios += f'''{item}: {self.__observacoes[item]}
147+
'''
157148

158149
return str_horarios
159150

160151
def __str__(self):
161-
return '''
162-
linha: {}
163-
ida: {}
164-
UTS: {} SAB: {} DOM: {}
165-
volta: {}
166-
UTS: {} SAB: {} DOM: {}
167-
'''.format(self.get_descricao_linha(),
168-
self.__desc_terminal_ida,
169-
len(self.__horarios_dia_util_ida),
170-
len(self.__horarios_sabado_ida),
171-
len(self.__horarios_domingo_ida),
172-
self.__desc_terminal_volta,
173-
len(self.__horarios_dia_util_volta),
174-
len(self.__horarios_sabado_volta),
175-
len(self.__horarios_domingo_volta))
152+
return f'''
153+
linha: {self.get_descricao_linha()}
154+
ida: {self.__desc_terminal_ida}
155+
UTS: {len(self.__horarios_dia_util_ida)}\tSAB: {len(self.__horarios_sabado_ida)}\tDOM: {len(self.__horarios_domingo_ida)}
156+
volta: {self.__desc_terminal_volta}
157+
UTS: {len(self.__horarios_dia_util_volta)}\tSAB: {len(self.__horarios_sabado_volta)}\tDOM: {len(self.__horarios_domingo_volta)}
158+
'''
176159

177160

178161
class HoraPartida():

app/telegram_proxy.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77

88

99
class TelegramProxy():
10-
__TELEGRAM_URL = 'https://api.telegram.org/bot{}/'.format(
11-
os.environ['TELEGRAM_BOT_TOKEN'])
10+
__TELEGRAM_URL = f"https://api.telegram.org/bot{os.environ['TELEGRAM_BOT_TOKEN']}/"
1211

1312
@staticmethod
1413
def enviar_mensagem(mensagem, id_chat):
1514
try:
1615
url_inicial = TelegramProxy.__TELEGRAM_URL + \
1716
'sendMessage?parse_mode=markdown&disable_web_page_preview=true&'
1817
params = {'chat_id': id_chat, 'text': mensagem}
19-
url = '{}{}'.format(
20-
url_inicial, urllib.parse.urlencode(params))
18+
url = f'{url_inicial}{urllib.parse.urlencode(params)}'
2119

2220
res = requests.get(url, timeout=2)
2321
return res.status_code == 200

0 commit comments

Comments
 (0)