From 1beaa1f1d655b8c55f69742f9d4407777e761fcf Mon Sep 17 00:00:00 2001 From: Carloshbfreire Date: Thu, 11 Aug 2022 14:33:59 -0300 Subject: [PATCH 1/5] =?UTF-8?q?Adicionada=20informa=C3=A7=C3=A3o=20sobre?= =?UTF-8?q?=20contribui=C3=A7=C3=A3o=20a=20projetos=20de=20c=C3=B3digo=20a?= =?UTF-8?q?bertos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 676c14d7f..d6a5adaff 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,5 @@ Tópicos a serem abordados: 3. Pip 4. Mock 5. Pipenv - \ No newline at end of file + +Revisando aula sobre Fork. \ No newline at end of file From 2b375615ede88a3ddd0e07c831fa8e6cfdf2a61c Mon Sep 17 00:00:00 2001 From: Carloshbfreire Date: Thu, 11 Aug 2022 15:02:00 -0300 Subject: [PATCH 2/5] Inserido a melhoria para o curos no Readme Carlos. close #724 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d6a5adaff..aa4572619 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,6 @@ Tópicos a serem abordados: 4. Mock 5. Pipenv -Revisando aula sobre Fork. \ No newline at end of file +Revisando aula sobre Fork. + +Link do Curso [Python pro](https://pythonpro.com.br/) \ No newline at end of file From 1381d9919327746f7fd3711f5c037af3a5bc1c21 Mon Sep 17 00:00:00 2001 From: Carloshbfreire Date: Thu, 18 Aug 2022 19:00:01 -0300 Subject: [PATCH 3/5] Suportada python 3 Carlinhos --- README.md | 2 +- libpythonpro/__init__.py | 1 - libpythonpro/github_api.py | 13 ----- libpythonpro/spam/__init__.py | 0 libpythonpro/spam/db.py | 31 ------------ libpythonpro/spam/enviador_de_email.py | 9 ---- libpythonpro/spam/main.py | 13 ----- libpythonpro/spam/modelos.py | 5 -- libpythonpro/tests/__init__.py | 0 libpythonpro/tests/test_exemplo.py | 2 - libpythonpro/tests/test_spam/__init__.py | 0 libpythonpro/tests/test_spam/conftest.py | 20 -------- .../tests/test_spam/test_enviador_de_email.py | 38 -------------- .../test_envio_para_base_de_usuarios.py | 49 ------------------- .../tests/test_spam/test_github_api.py | 28 ----------- libpythonpro/tests/test_spam/test_usuarios.py | 17 ------- 16 files changed, 1 insertion(+), 227 deletions(-) delete mode 100644 libpythonpro/__init__.py delete mode 100644 libpythonpro/github_api.py delete mode 100644 libpythonpro/spam/__init__.py delete mode 100644 libpythonpro/spam/db.py delete mode 100644 libpythonpro/spam/enviador_de_email.py delete mode 100644 libpythonpro/spam/main.py delete mode 100644 libpythonpro/spam/modelos.py delete mode 100644 libpythonpro/tests/__init__.py delete mode 100644 libpythonpro/tests/test_exemplo.py delete mode 100644 libpythonpro/tests/test_spam/__init__.py delete mode 100644 libpythonpro/tests/test_spam/conftest.py delete mode 100644 libpythonpro/tests/test_spam/test_enviador_de_email.py delete mode 100644 libpythonpro/tests/test_spam/test_envio_para_base_de_usuarios.py delete mode 100644 libpythonpro/tests/test_spam/test_github_api.py delete mode 100644 libpythonpro/tests/test_spam/test_usuarios.py diff --git a/README.md b/README.md index aa4572619..4458e74f9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Link para o curso [Python Pro](https://www.python.pro.br/) [![Python 3](https://pyup.io/repos/github/pythonprobr/libpythonpro/python-3-shield.svg)](https://pyup.io/repos/github/pythonprobr/libpythonpro/) [![codecov](https://codecov.io/gh/pythonprobr/libpythonpro/branch/master/graph/badge.svg)](https://codecov.io/gh/pythonprobr/libpythonpro) -Suportada versão 3 de Python +Suportada versão 3 de Python Carlinhos Para instalar: diff --git a/libpythonpro/__init__.py b/libpythonpro/__init__.py deleted file mode 100644 index b650ceb08..000000000 --- a/libpythonpro/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '0.2' diff --git a/libpythonpro/github_api.py b/libpythonpro/github_api.py deleted file mode 100644 index 8b0fbafb9..000000000 --- a/libpythonpro/github_api.py +++ /dev/null @@ -1,13 +0,0 @@ -import requests - - -def buscar_avatar(usuario): - """ - Busca o avatar de um usuário no Github - - :param usuario: str com o nome de usuário no github - :return: str com o link do avatar - """ - url = f'https://api.github.com/users/{usuario}' - resp = requests.get(url) - return resp.json()['avatar_url'] diff --git a/libpythonpro/spam/__init__.py b/libpythonpro/spam/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/libpythonpro/spam/db.py b/libpythonpro/spam/db.py deleted file mode 100644 index ce90ca60b..000000000 --- a/libpythonpro/spam/db.py +++ /dev/null @@ -1,31 +0,0 @@ -from time import sleep - - -class Sessao: - contador = 0 - usuarios = [] - - def salvar(self, usuario): - Sessao.contador += 1 - usuario.id = Sessao.contador - self.usuarios.append(usuario) - - def listar(self): - return self.usuarios - - def roll_back(self): - self.usuarios.clear() - - def fechar(self): - pass - - -class Conexao: - def __init__(self): - sleep(1) - - def gerar_sessao(self): - return Sessao() - - def fechar(self): - pass diff --git a/libpythonpro/spam/enviador_de_email.py b/libpythonpro/spam/enviador_de_email.py deleted file mode 100644 index fa0952223..000000000 --- a/libpythonpro/spam/enviador_de_email.py +++ /dev/null @@ -1,9 +0,0 @@ -class Enviador: - def enviar(self, remetente, destinatario, assunto, corpo): - if '@' not in remetente: - raise EmailInvalido(f'Email de remetente inválido: {remetente}') - return remetente - - -class EmailInvalido(Exception): - pass diff --git a/libpythonpro/spam/main.py b/libpythonpro/spam/main.py deleted file mode 100644 index f81821ae4..000000000 --- a/libpythonpro/spam/main.py +++ /dev/null @@ -1,13 +0,0 @@ -class EnviadorDeSpam: - def __init__(self, sessao, enviador): - self.sessao = sessao - self.enviador = enviador - - def enviar_emails(self, remetente, assunto, corpo): - for usuario in self.sessao.listar(): - self.enviador.enviar( - remetente, - usuario.email, - assunto, - corpo - ) diff --git a/libpythonpro/spam/modelos.py b/libpythonpro/spam/modelos.py deleted file mode 100644 index 093b35a2a..000000000 --- a/libpythonpro/spam/modelos.py +++ /dev/null @@ -1,5 +0,0 @@ -class Usuario: - def __init__(self, nome, email): - self.email = email - self.nome = nome - self.id = None diff --git a/libpythonpro/tests/__init__.py b/libpythonpro/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/libpythonpro/tests/test_exemplo.py b/libpythonpro/tests/test_exemplo.py deleted file mode 100644 index 78cd50236..000000000 --- a/libpythonpro/tests/test_exemplo.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_int(): - assert 1 == 1 diff --git a/libpythonpro/tests/test_spam/__init__.py b/libpythonpro/tests/test_spam/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/libpythonpro/tests/test_spam/conftest.py b/libpythonpro/tests/test_spam/conftest.py deleted file mode 100644 index a16f3970a..000000000 --- a/libpythonpro/tests/test_spam/conftest.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest - -from libpythonpro.spam.db import Conexao - - -@pytest.fixture(scope='session') -def conexao(): - # Setup - conexao_obj = Conexao() - yield conexao_obj - # Tear Down - conexao_obj.fechar() - - -@pytest.fixture -def sessao(conexao): - sessao_obj = conexao.gerar_sessao() - yield sessao_obj - sessao_obj.roll_back() - sessao_obj.fechar() diff --git a/libpythonpro/tests/test_spam/test_enviador_de_email.py b/libpythonpro/tests/test_spam/test_enviador_de_email.py deleted file mode 100644 index c72a0bbe9..000000000 --- a/libpythonpro/tests/test_spam/test_enviador_de_email.py +++ /dev/null @@ -1,38 +0,0 @@ -import pytest - -from libpythonpro.spam.enviador_de_email import EmailInvalido, Enviador - - -def test_criar_enviador_de_email(): - enviador = Enviador() - assert enviador is not None - - -@pytest.mark.parametrize( - 'remetente', - ['foo@bar.com.br', 'renzo@python.pro.br'] -) -def test_remetente(remetente): - enviador = Enviador() - resultado = enviador.enviar( - remetente, - 'luciano@python.pro.br', - 'Cursos Python Pro', - 'Primeira turma Guido Von Rossum aberta.' - ) - assert remetente in resultado - - -@pytest.mark.parametrize( - 'remetente', - ['', 'renzo'] -) -def test_remetente_invalido(remetente): - enviador = Enviador() - with pytest.raises(EmailInvalido): - enviador.enviar( - remetente, - 'luciano@python.pro.br', - 'Cursos Python Pro', - 'Primeira turma Guido Von Rossum aberta.' - ) diff --git a/libpythonpro/tests/test_spam/test_envio_para_base_de_usuarios.py b/libpythonpro/tests/test_spam/test_envio_para_base_de_usuarios.py deleted file mode 100644 index d2db43893..000000000 --- a/libpythonpro/tests/test_spam/test_envio_para_base_de_usuarios.py +++ /dev/null @@ -1,49 +0,0 @@ -from unittest.mock import Mock - -import pytest - -from libpythonpro.spam.main import EnviadorDeSpam -from libpythonpro.spam.modelos import Usuario - - -@pytest.mark.parametrize( - 'usuarios', - [ - [ - Usuario(nome='Renzo', email='renzo@python.pro.br'), - Usuario(nome='Luciano', email='renzo@python.pro.br') - ], - [ - Usuario(nome='Renzo', email='renzo@python.pro.br') - ] - ] -) -def test_qde_de_spam(sessao, usuarios): - for usuario in usuarios: - sessao.salvar(usuario) - enviador = Mock() - enviador_de_spam = EnviadorDeSpam(sessao, enviador) - enviador_de_spam.enviar_emails( - 'renzo@python.pro.br', - 'Curso Python Pro', - 'Confira os módulos fantásticos' - ) - assert len(usuarios) == enviador.enviar.call_count - - -def test_parametros_de_spam(sessao): - usuario = Usuario(nome='Renzo', email='renzo@python.pro.br') - sessao.salvar(usuario) - enviador = Mock() - enviador_de_spam = EnviadorDeSpam(sessao, enviador) - enviador_de_spam.enviar_emails( - 'luciano@python.pro.br', - 'Curso Python Pro', - 'Confira os módulos fantásticos' - ) - enviador.enviar.assert_called_once_with( - 'luciano@python.pro.br', - 'renzo@python.pro.br', - 'Curso Python Pro', - 'Confira os módulos fantásticos' - ) diff --git a/libpythonpro/tests/test_spam/test_github_api.py b/libpythonpro/tests/test_spam/test_github_api.py deleted file mode 100644 index 21ce9c5d0..000000000 --- a/libpythonpro/tests/test_spam/test_github_api.py +++ /dev/null @@ -1,28 +0,0 @@ -from unittest.mock import Mock - -import pytest - -from libpythonpro import github_api - - -@pytest.fixture -def avatar_url(mocker): - resp_mock = Mock() - url = 'https://avatars3.githubusercontent.com/u/402714?v=4' - resp_mock.json.return_value = { - 'login': 'renzo', 'id': 402714, - 'avatar_url': url, - } - get_mock = mocker.patch('libpythonpro.github_api.requests.get') - get_mock.return_value = resp_mock - return url - - -def test_buscar_avatar(avatar_url): - url = github_api.buscar_avatar('renzo') - assert avatar_url == url - - -def test_buscar_avatar_integracao(): - url = github_api.buscar_avatar('renzon') - assert 'https://avatars3.githubusercontent.com/u/3457115?v=4' == url diff --git a/libpythonpro/tests/test_spam/test_usuarios.py b/libpythonpro/tests/test_spam/test_usuarios.py deleted file mode 100644 index 09b523445..000000000 --- a/libpythonpro/tests/test_spam/test_usuarios.py +++ /dev/null @@ -1,17 +0,0 @@ -from libpythonpro.spam.modelos import Usuario - - -def test_salvar_usuario(sessao): - usuario = Usuario(nome='Renzo', email='renzo@python.pro.br') - sessao.salvar(usuario) - assert isinstance(usuario.id, int) - - -def test_listar_usuarios(sessao): - usuarios = [ - Usuario(nome='Renzo', email='renzo@python.pro.br'), - Usuario(nome='Luciano', email='renzo@python.pro.br') - ] - for usuario in usuarios: - sessao.salvar(usuario) - assert usuarios == sessao.listar() From b424cd73b2434a2c68af6566a0b00f51e52fccb2 Mon Sep 17 00:00:00 2001 From: Carloshbfreire Date: Mon, 22 Aug 2022 16:21:35 -0300 Subject: [PATCH 4/5] =?UTF-8?q?Adicionada=20flake8=20como=20depend=C3=AAnc?= =?UTF-8?q?ia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #12 --- Libpythonpro/__init__.py | 0 Libpythonpro/github_api.py | 16 ++++++++++++++++ README.md | 7 ++++--- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 Libpythonpro/__init__.py create mode 100644 Libpythonpro/github_api.py diff --git a/Libpythonpro/__init__.py b/Libpythonpro/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Libpythonpro/github_api.py b/Libpythonpro/github_api.py new file mode 100644 index 000000000..abc64ed4d --- /dev/null +++ b/Libpythonpro/github_api.py @@ -0,0 +1,16 @@ +import requests + + +def buscar_avatar(usuario): + """ + Busca o avatar de um usuário no Github + :Param usuário: str com o nome usuário no github + :return: str com o link do avatar + """ + url = f'https://api.github.com/users/{usuario}' + resp = requests.get(url) + return resp.json()['avatar_url'] + + +if __name__ == '__main__': + print(buscar_avatar('Carloshbfreire')) diff --git a/README.md b/README.md index 4458e74f9..b7a10cea4 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,15 @@ Suportada versão 3 de Python Carlinhos Para instalar: ```console -pip install pipenv -pipenv install --dev +python3 -m venv .venv +source .venv/bin/activete +pip install -r requirements-dev.txt ``` Para conferir qualidade de código: ```console -pipenv run flake8 +flake8 ``` Tópicos a serem abordados: From 66da9a08ff05df5decf5451647ce8552568355cf Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Thu, 25 Aug 2022 01:09:41 -0300 Subject: [PATCH 5/5] Update importlib-metadata from 0.18 to 4.12.0 --- Pipfile.lock | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index 8a647ca6f..91cb9b9c8 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -121,11 +121,8 @@ "version": "==3.7.7" }, "importlib-metadata": { - "hashes": [ - "sha256:6dfd58dfe281e8d240937776065dd3624ad5469c835248219bd16cf2e12dbeb7", - "sha256:cb6ee23b46173539939964df59d3d72c3e0c1b5d54b84f1d8a7e912fe43612db" - ], - "version": "==0.18" + "hashes": [], + "version": "==4.12.0" }, "mccabe": { "hashes": [