Skip to content

Commit

Permalink
Merge branch 'feature/local-storage-path-86' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Grangier committed Apr 21, 2014
2 parents cd54783 + d935872 commit 9c217d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions goose/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def __init__(self):
# Parser type
self.parser_class = 'lxml'

@property
def local_storage_path(self):
return os.path.join(tempfile.gettempdir(), 'goose')
# set the local storage path
# make this configurable
self.local_storage_path = os.path.join(tempfile.gettempdir(), 'goose')

def get_parser(self):
return Parser if self.parser_class == 'lxml' else ParserSoup
Expand Down
15 changes: 11 additions & 4 deletions tests/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import tempfile
import unittest

from goose.configuration import Configuration
from goose import Goose


class TestTempDir(unittest.TestCase):

def test_tmp_not_overwritten(self):
def test_tmp_defaut(self):
g = Goose()
default_local_storage_path = os.path.join(tempfile.gettempdir(), 'goose')
self.assertEquals(g.config.local_storage_path, default_local_storage_path)

def test_tmp_overwritten(self):
path = '/this/directory/does/not/exist/i/assume/'
config = Configuration()
self.assertRaises(AttributeError, lambda: setattr(config, 'local_storage_path', path))
g = Goose({'local_storage_path': path})
self.assertEquals(g.config.local_storage_path, path)

0 comments on commit 9c217d1

Please sign in to comment.