-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
c256ab7
commit a41e3f2
Showing
2 changed files
with
34 additions
and
1 deletion.
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
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 | ||
from unittest.mock import patch | ||
from myCripto_Monitor import monitorar_criptomoeda, criar_tabela | ||
|
||
class TestMyCriptoMonitor(unittest.TestCase): | ||
|
||
@patch('myCripto_Monitor.loop') | ||
@patch('myCripto_Monitor.locale.currency') | ||
@patch('myCripto_Monitor.calc_porc') | ||
def test_monitorar_criptomoeda(self, mock_calc_porc, mock_currency, mock_loop): | ||
# Configurando mocks | ||
mock_loop.side_effect = [100, 110] # Simula valores retornados pela função loop | ||
mock_currency.return_value = "R$100,00" # Simula o valor retornado pela função locale.currency | ||
mock_calc_porc.return_value = "10%" # Simula o valor retornado pela função calc_porc | ||
|
||
# Testando monitorar_criptomoeda | ||
valor, porcentagem, estilo = monitorar_criptomoeda('btc', [1.00]) | ||
self.assertEqual(valor, "R$100,00") | ||
self.assertEqual(porcentagem, "10%") | ||
self.assertEqual(estilo, "green") | ||
|
||
def test_criar_tabela(self): | ||
# Testando criar_tabela | ||
tabela = criar_tabela() | ||
self.assertEqual(len(tabela.columns), 5) | ||
self.assertEqual(tabela.columns[0].name, "Criptomoeda") | ||
self.assertEqual(tabela.columns[1].name, "Valor") | ||
self.assertEqual(tabela.columns[2].name, "Data/Hora") | ||
self.assertEqual(tabela.columns[3].name, "Status") | ||
self.assertEqual(tabela.columns[4].name, "Porcentagem") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |