Skip to content

Commit

Permalink
grangier#188 - move image test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Grangier committed Dec 31, 2014
1 parent 6009d44 commit 26ba835
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tests/extractors/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ class MockResponseImage(MockResponse):
def image_content(self, req):
md5_hash = hashlib.md5(req.get_full_url()).hexdigest()
current_test = self.cls._get_current_testname()
path = os.path.join(CURRENT_PATH, "data", "images", current_test, md5_hash)
path = os.path.join(
os.path.dirname(CURRENT_PATH),
"data",
"extractors",
"images",
current_test,
md5_hash)
path = os.path.abspath(path)
f = open(path, 'rb')
content = f.read()
Expand All @@ -52,7 +58,13 @@ def image_content(self, req):

def html_content(self, req):
current_test = self.cls._get_current_testname()
path = os.path.join(CURRENT_PATH, "data", "images", current_test, "%s.html" % current_test)
path = os.path.join(
os.path.dirname(CURRENT_PATH),
"data",
"extractors",
"images",
current_test,
"%s.html" % current_test)
path = os.path.abspath(path)
return FileHelper.loadResourceFile(path)

Expand All @@ -72,8 +84,15 @@ def loadData(self):
"""\
"""
suite, module, cls, func = self.id().split('.')
path = os.path.join(CURRENT_PATH, "data", module, func, "%s.json" % func)
test, suite, module, cls, func = self.id().split('.')
path = os.path.join(
os.path.dirname(CURRENT_PATH),
"data",
suite,
module,
func,
"%s.json" % func)

path = os.path.abspath(path)
content = FileHelper.loadResourceFile(path)
self.data = json.loads(content)
Expand Down Expand Up @@ -158,7 +177,7 @@ def test_opengraph_tag(self):
class ImageUtilsTests(unittest.TestCase):

def setUp(self):
self.path = 'tests/data/images/test_basic_image/50850547cc7310bc53e30e802c6318f1'
self.path = 'tests/data/extractors/images/test_basic_image/50850547cc7310bc53e30e802c6318f1'
self.expected_results = {
'width': 476,
'height': 317,
Expand Down

0 comments on commit 26ba835

Please sign in to comment.