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

Commit

Permalink
fix test for bad folder input
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Sep 22, 2015
1 parent e886803 commit ff55ccd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 0 additions & 6 deletions topik/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,11 @@ def read_input(source, content_field, source_type="auto",
True
"""

import re
import time
json_extensions = [".js", ".json"]
ip_regex = "/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
web_regex = "^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/"
if output_args is None:
output_args = {}

ip_match = re.compile(ip_regex)
web_match = re.compile(web_regex)

# solr defaults to port 8983
if (source_type == "auto" and "8983" in source) or source_type == "solr":
data_iterator = _iter_solr_query(source, **kwargs)
Expand Down
11 changes: 7 additions & 4 deletions topik/tests/test_readers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from functools import partial

import nose.tools as nt
import elasticsearch
Expand Down Expand Up @@ -57,8 +58,8 @@ def setUp(self):

def tearDown(self):
instance = elasticsearch.Elasticsearch("localhost")
if instance.indices.exists("test_elastic"):
instance.indices.delete("test_elastic")
if instance.indices.exists(INDEX):
instance.indices.delete(INDEX)

def test_read_document_json_stream(self):
iterable_data = read_input('{}/test_data_json_stream.json'.format(
Expand Down Expand Up @@ -88,7 +89,7 @@ def test_iter_large_json(self):

def test_elastic_import(self):
output_args = {'host': 'localhost',
'index': "test_elastic"}
'index': INDEX}
# import data from file into known elastic server
read_input('{}/test_data_json_stream.json'.format(
test_data_path), content_field="abstract",
Expand All @@ -97,8 +98,10 @@ def test_elastic_import(self):
iterable_data = read_input("localhost:9200/"+INDEX, content_field="abstract")
self.assertEquals(len(iterable_data), 100)


def test_bad_folder():
nt.assert_raises(IOError, readers._iter_documents_folder, "Frank")
nt.assert_raises(IOError, next, readers._iter_documents_folder("Frank"))


if __name__ == '__main__':
unittest.main()

0 comments on commit ff55ccd

Please sign in to comment.