forked from ofek/pypinfo
-
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.
Merge pull request ofek#72 from odufrn/development
Versão 1.1.0
- Loading branch information
Showing
10 changed files
with
139 additions
and
26 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
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setuptools.setup( | ||
name="odufrn_downloader", | ||
version="1.0.2", | ||
version="1.1.0", | ||
author="Open Data UFRN", | ||
author_email="[email protected]", | ||
description="Open Data UFRN Downloader", | ||
|
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,32 @@ | ||
from .utils import * | ||
import tempfile | ||
|
||
|
||
class Group(unittest.TestCase): | ||
def setUp(self): | ||
"""Inicia novo objeto em todo os testes """ | ||
self.ufrn_data = ODUFRNDownloader() | ||
|
||
def test_can_download_packages_from_file(self): | ||
"""Verifica se dado um arquivo com pacotes realiza-se download.""" | ||
with tempfile.NamedTemporaryFile() as tmp: | ||
tmp.write(b'telefones\n') | ||
tmp.write(b'unidades-academicas') | ||
tmp.seek(0) | ||
self.ufrn_data.download_from_file(tmp.name, './tmp') | ||
path_telefones = os.path.exists('./tmp/telefones') | ||
path_unidades = os.path.exists('./tmp/unidades-academicas') | ||
self.assertTrue( | ||
path_telefones and path_unidades | ||
) | ||
if os.path.exists('./tmp'): | ||
shutil.rmtree('./tmp') | ||
|
||
def test_can_print_exception_download_packages_from_file(self): | ||
"""Verifica se dado um arquivo com nomes errados de pacotes | ||
lança-se exceção.""" | ||
assert_console( | ||
lambda: self.ufrn_data.download_from_file( | ||
'potato', './tmp' | ||
) | ||
) |
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
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 |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import io | ||
import os | ||
import sys | ||
import shutil | ||
import unittest | ||
from os.path import dirname, join, abspath | ||
sys.path.insert(0, abspath(join(dirname(__file__), '..'))) | ||
from odufrn_downloader import ODUFRNDownloader | ||
|
||
|
||
def assert_console(output): | ||
""" Recebe função que printa algo na tela e realiza assert | ||
que verifica se foi printado.""" | ||
unit = unittest.TestCase() | ||
def input_value(fun): | ||
"""Recebe função que imprime algo na tela e retorna impressao.""" | ||
capturedOutput = io.StringIO() | ||
sys.stdout = capturedOutput | ||
output() | ||
fun() | ||
sys.stdout = sys.__stdout__ | ||
return unit.assertTrue(len(capturedOutput.getvalue()) > 0) | ||
return capturedOutput.getvalue() | ||
|
||
|
||
def assert_console(fun): | ||
"""Recebe função que printa algo na tela e realiza assert | ||
que verifica se foi printado.""" | ||
unit = unittest.TestCase() | ||
return unit.assertTrue(len(input_value(fun)) > 0) |