Skip to content

Commit

Permalink
🆒 Correção das falhas nos testes.
Browse files Browse the repository at this point in the history
Co-authored-by: Bianca Patrocínio <[email protected]>
  • Loading branch information
BrunoHDuarte2 and BiancaPatrocinio7 committed Dec 10, 2023
1 parent bccdea1 commit 281f7e4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
Binary file modified .coverage
Binary file not shown.
Binary file modified Testes/__pycache__/test_WebScraper.cpython-310-pytest-7.4.3.pyc
Binary file not shown.
28 changes: 19 additions & 9 deletions Testes/test_WebScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_move_txt(self):

# Chame a função para mover o arquivo
self.coletor.move_txt('testes')

print(diretorio_atual)
# Verifique se o arquivo foi movido para a pasta correta
self.assertFalse(os.path.exists('arquivo1.txt')) # Verifica se o arquivo original não existe mais
self.assertTrue(os.path.exists(os.path.join(f'{caminho_atual}/Camada_Dados/txt/testes', 'arquivo1.txt'))) # Verifica se o arquivo foi movido para o destino esperado
Expand All @@ -44,29 +44,39 @@ def test_apaga_pdf(self):
caminho_atual = os.path.abspath(os.path.join(diretorio_atual, '..'))

# Mova o arquivo para o diretório acima
shutil.move(os.path.join(diretorio_atual, 'arquivo.pdf'), os.path.join(caminho_atual, 'arquivo.pdf'))

try:
shutil.move(os.path.join(diretorio_atual, 'arquivo.pdf'), os.path.join(caminho_atual, 'arquivo.pdf'))
except:
pass
# Verifique se o arquivo foi movido com sucesso
self.assertTrue(os.path.exists(os.path.join(caminho_atual, 'arquivo.pdf')))

# Chame o método que você está testando
self.coletor.apaga_pdf('arquivo.pdf')

try:
self.coletor.apaga_pdf(f'{caminho_atual}/arquivo.pdf')
except:
self.coletor.apaga_pdf(f'arquivo.pdf')

# Verifique se o arquivo foi removido
self.assertFalse(os.path.exists(os.path.join(caminho_atual, 'arquivo.pdf')))

def test_altera_diretorio(self):
diretorio_atual = os.path.dirname(os.path.abspath(__file__))
# Crie um arquivo fictício
open('2023-01-01.pdf', 'w').close()
open(f'{diretorio_atual}/2023-01-01.pdf', 'w').close()
caminho_downloads = os.path.join(os.path.expanduser("~"), "Downloads")

diretorio_atual = os.path.dirname(os.path.abspath(__file__))

shutil.move(f'{diretorio_atual}/2023-01-01.pdf', caminho_downloads)

try:
shutil.move(f'{diretorio_atual}/2023-01-01.pdf', caminho_downloads)
except:
pass
# Execute o método altera_diretorio
ano, mes, dia = self.coletor.altera_diretorio()

print (ano)
print (mes)
print (dia)
self.assertEqual(ano, '2023')
self.assertEqual(mes, '01')
self.assertEqual(dia, '01')
Expand Down
50 changes: 32 additions & 18 deletions coverage.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" ?>
<coverage version="7.3.2" timestamp="1702081077504" lines-valid="158" lines-covered="148" line-rate="0.9367" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<coverage version="7.3.2" timestamp="1702168517298" lines-valid="172" lines-covered="167" line-rate="0.9709" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.3.2 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/home/bdebatata/MétodosDeDesenvolvimentoDeSoftware/2023-2-Squad08/Testes</source>
</sources>
<packages>
<package name="." line-rate="0.9367" branch-rate="0" complexity="0">
<package name="." line-rate="0.9709" branch-rate="0" complexity="0">
<classes>
<class name="__init__.py" filename="__init__.py" complexity="0" line-rate="1" branch-rate="0">
<methods/>
Expand Down Expand Up @@ -124,7 +124,7 @@
<line number="114" hits="0"/>
</lines>
</class>
<class name="test_WebScraper.py" filename="test_WebScraper.py" complexity="0" line-rate="0.8571" branch-rate="0">
<class name="test_WebScraper.py" filename="test_WebScraper.py" complexity="0" line-rate="0.9571" branch-rate="0">
<methods/>
<lines>
<line number="1" hits="1"/>
Expand All @@ -147,42 +147,56 @@
<line number="25" hits="1"/>
<line number="27" hits="1"/>
<line number="30" hits="1"/>
<line number="31" hits="1"/>
<line number="33" hits="1"/>
<line number="34" hits="1"/>
<line number="36" hits="1"/>
<line number="38" hits="1"/>
<line number="41" hits="1"/>
<line number="44" hits="1"/>
<line number="47" hits="1"/>
<line number="50" hits="0"/>
<line number="53" hits="0"/>
<line number="56" hits="0"/>
<line number="48" hits="1"/>
<line number="49" hits="1"/>
<line number="50" hits="1"/>
<line number="52" hits="1"/>
<line number="55" hits="1"/>
<line number="56" hits="1"/>
<line number="57" hits="1"/>
<line number="58" hits="1"/>
<line number="60" hits="1"/>
<line number="61" hits="1"/>
<line number="63" hits="1"/>
<line number="65" hits="1"/>
<line number="68" hits="0"/>
<line number="70" hits="0"/>
<line number="71" hits="0"/>
<line number="72" hits="0"/>
<line number="74" hits="1"/>
<line number="75" hits="1"/>
<line number="64" hits="1"/>
<line number="66" hits="1"/>
<line number="67" hits="1"/>
<line number="69" hits="1"/>
<line number="71" hits="1"/>
<line number="72" hits="1"/>
<line number="73" hits="0"/>
<line number="74" hits="0"/>
<line number="76" hits="1"/>
<line number="77" hits="1"/>
<line number="78" hits="1"/>
<line number="79" hits="1"/>
<line number="80" hits="1"/>
<line number="81" hits="1"/>
<line number="82" hits="1"/>
<line number="83" hits="1"/>
<line number="84" hits="1"/>
<line number="85" hits="1"/>
<line number="86" hits="1"/>
<line number="87" hits="1"/>
<line number="88" hits="1"/>
<line number="89" hits="1"/>
<line number="90" hits="1"/>
<line number="95" hits="1"/>
<line number="96" hits="0"/>
<line number="91" hits="1"/>
<line number="92" hits="1"/>
<line number="93" hits="1"/>
<line number="94" hits="1"/>
<line number="96" hits="1"/>
<line number="97" hits="1"/>
<line number="98" hits="1"/>
<line number="99" hits="1"/>
<line number="100" hits="1"/>
<line number="105" hits="1"/>
<line number="106" hits="0"/>
</lines>
</class>
</classes>
Expand Down

0 comments on commit 281f7e4

Please sign in to comment.