Skip to content
This repository has been archived by the owner on Mar 1, 2018. It is now read-only.

Commit

Permalink
Update dataset by default (and mock it for tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos committed May 23, 2017
1 parent 5d7f157 commit efe32b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rosie/federal_senate/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Adapter:

def __init__(self, path):
self.path = path
self.dataset_path = os.path.join(self.path, 'federal_senate_reimbursements.xz')

@property
def dataset(self):
self._dataset = pd.read_csv(self.dataset_path, dtype={'cnpj_cpf': np.str}, encoding='utf-8')
path = self.update_datasets()
self._dataset = pd.read_csv(path, dtype={'cnpj_cpf': np.str}, encoding='utf-8')
self.prepare_dataset()
return self._dataset

Expand Down
6 changes: 4 additions & 2 deletions rosie/federal_senate/tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil
from tempfile import mkdtemp
from unittest import TestCase
from unittest.mock import patch

import pandas as pd

Expand All @@ -20,8 +21,9 @@ class TestAdapter(TestCase):
def setUp(self):
self.temp_path = mkdtemp()
subject = subject_class(self.temp_path)
subject.dataset_path = FIXTURE_PATH
self.dataset = subject.dataset
with patch.object(subject_class, 'update_datasets') as mocked_update:
mocked_update.return_value = FIXTURE_PATH
self.dataset = subject.dataset

def tearDown(self):
shutil.rmtree(self.temp_path)
Expand Down

0 comments on commit efe32b9

Please sign in to comment.