-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
599ff0c
commit 3831eaf
Showing
14 changed files
with
465 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.circulacao_viaria import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.circulacao_viaria.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.circulacao_viaria.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/circulacao-viaria-no-do-trecho') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch, MagicMock | ||
import pandas as pd | ||
from src.loader.estacionamento_rotativo_idoso import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.estacionamento_rotativo_idoso.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.estacionamento_rotativo_idoso.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/estacionamento_idoso') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.estacionamento_rotativo import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.estacionamento_rotativo.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.estacionamento_rotativo.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/faces-de-quadras-regulamentadas-com-estacionamento-rotativo') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.estacionamento_rotativo_motofrete import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.estacionamento_rotativo_motofrete.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.estacionamento_rotativo_motofrete.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/estacionamento-rotativo-para-motofrete') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
36 changes: 36 additions & 0 deletions
36
tests/loader/test_logradouros_acidentes_transito_vitima.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.logradouros_acidentes_transito_vitima import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.logradouros_acidentes_transito_vitima.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.logradouros_acidentes_transito_vitima.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/relacao-dos-logradouros-dos-locais-de-acidentes-de-transito-com-vitima') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
36 changes: 36 additions & 0 deletions
36
tests/loader/test_ocorrencias_acidentes_transito_vitima.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.ocorrencias_acidentes_transito_vitima import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.ocorrencias_acidentes_transito_vitima.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.ocorrencias_acidentes_transito_vitima.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/relacao-de-ocorrencias-de-acidentes-de-transito-com-vitima') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.pessoas_acidentes_transito_vitima import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.pessoas_acidentes_transito_vitima.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.pessoas_acidentes_transito_vitima.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/relacao-das-pessoas-envolvidas-nos-acidentes-de-transito-com-vitima') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.posto_venda_rotativo import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.posto_venda_rotativo.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.posto_venda_rotativo.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/posto-de-venda-rotativo') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.redutor_velocidade import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.redutor_velocidade.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.redutor_velocidade.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/redutor-de-velocidade') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import pandas as pd | ||
from src.loader.sinalizacao_semaforica import main | ||
|
||
|
||
@pytest.fixture | ||
def mock_s3(): | ||
with patch('src.loader.sinalizacao_semaforica.S3') as MockS3: | ||
mock_s3 = MockS3.return_value | ||
yield mock_s3 | ||
|
||
|
||
@pytest.fixture | ||
def mock_send_to_db(): | ||
with patch('src.loader.sinalizacao_semaforica.send_to_db') as mock_send: | ||
yield mock_send | ||
|
||
|
||
def test_main(mock_s3, mock_send_to_db): | ||
# Mocking S3 list_files method | ||
mock_s3.list_files.return_value = (['path/to/file1.csv', 'path/to/file2.csv'], ['file1.csv', 'file2.csv'], None) | ||
|
||
df_mock = pd.DataFrame({'col1': [1, 2], 'col2': ['a', 'b']}) | ||
mock_s3.read_to_df.return_value = df_mock | ||
|
||
main() | ||
|
||
mock_s3.list_files.assert_called_once_with(prefix='gold/localizacao-das-sinalizacoes-semaforicas') | ||
assert mock_s3.read_to_df.call_count == 2 | ||
mock_send_to_db.assert_called_once() | ||
|
||
called_df = mock_send_to_db.call_args[0][0] | ||
assert called_df.shape == (4, 2) | ||
assert called_df.columns.tolist() == ['col1', 'col2'] | ||
|
Oops, something went wrong.