-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆒(#80): Teste da escrita no arquivo json na extração de dados com o r…
…egex
- Loading branch information
1 parent
9c89883
commit cbf3bf9
Showing
6 changed files
with
48 additions
and
18 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-4 Bytes
(100%)
Testes/__pycache__/test_WebScraper.cpython-310-pytest-7.4.3.pyc
Binary file not shown.
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,33 @@ | ||
import unittest | ||
import os | ||
import json | ||
from Camada_Dados.Regex import Extrator_de_dados | ||
|
||
class Test_extrator_de_dados(unittest.TestCase): | ||
def setUp(self): | ||
self.extrator = Extrator_de_dados() | ||
|
||
def test_escrita_database(self): | ||
# Criação do arquivo temporario na pasta geral do projeto | ||
diretorio_atual = os.path.dirname(os.path.abspath(__file__)) | ||
caminho_atual = os.path.abspath(os.path.join(diretorio_atual, '..')) | ||
open(f'{caminho_atual}/testeRegex.json', 'w').close() | ||
with open(f'{caminho_atual}/testeRegex.json', 'w') as file: | ||
file.write("[\n\n]") | ||
|
||
dados_ficticios = { | ||
"nomeMunicipio": "nome_ficticio", | ||
"dataPost": "data_ficticia", | ||
"haNomeacao": "nomeacao_ficticia", | ||
"haExoneracao": "exoneracao_ficticia", | ||
} | ||
self.extrator.escrita_data_base(dados_ficticios, f'{caminho_atual}/testeRegex.json') | ||
|
||
|
||
with open(f'{caminho_atual}/testeRegex.json', 'r') as arquivo: | ||
dados_lidos = json.load(arquivo) | ||
|
||
self.assertEqual(dados_lidos[0], dados_ficticios) | ||
os.remove(f'{caminho_atual}/testeRegex.json') | ||
if __name__ == '__main__': | ||
unittest.main() |