From 26ba835b5aeab2e3f0aeda024192ee6725837005 Mon Sep 17 00:00:00 2001 From: Xavier Grangier Date: Wed, 31 Dec 2014 06:32:34 +0100 Subject: [PATCH] #188 - move image test case --- .../50850547cc7310bc53e30e802c6318f1 | Bin .../test_basic_image/test_basic_image.html | 0 .../test_basic_image/test_basic_image.json | 0 .../test_known_image_css_class.html | 0 .../test_known_image_css_class.json | 0 .../test_known_image_css_id.html | 0 .../test_known_image_css_id.json | 0 .../test_known_image_css_parent_class.html | 0 .../test_known_image_css_parent_class.json | 0 .../test_known_image_css_parent_id.html | 0 .../test_known_image_css_parent_id.json | 0 .../test_known_image_empty_src.html | 0 .../test_known_image_empty_src.json | 0 .../test_known_image_name_parent.html | 0 .../test_known_image_name_parent.json | 0 .../test_opengraph_tag.html | 0 .../test_opengraph_tag.json | 0 tests/extractors/images.py | 29 +++++++++++++++--- 18 files changed, 24 insertions(+), 5 deletions(-) rename tests/data/{ => extractors}/images/test_basic_image/50850547cc7310bc53e30e802c6318f1 (100%) rename tests/data/{ => extractors}/images/test_basic_image/test_basic_image.html (100%) rename tests/data/{ => extractors}/images/test_basic_image/test_basic_image.json (100%) rename tests/data/{ => extractors}/images/test_known_image_css_class/test_known_image_css_class.html (100%) rename tests/data/{ => extractors}/images/test_known_image_css_class/test_known_image_css_class.json (100%) rename tests/data/{ => extractors}/images/test_known_image_css_id/test_known_image_css_id.html (100%) rename tests/data/{ => extractors}/images/test_known_image_css_id/test_known_image_css_id.json (100%) rename tests/data/{ => extractors}/images/test_known_image_css_parent_class/test_known_image_css_parent_class.html (100%) rename tests/data/{ => extractors}/images/test_known_image_css_parent_class/test_known_image_css_parent_class.json (100%) rename tests/data/{ => extractors}/images/test_known_image_css_parent_id/test_known_image_css_parent_id.html (100%) rename tests/data/{ => extractors}/images/test_known_image_css_parent_id/test_known_image_css_parent_id.json (100%) rename tests/data/{ => extractors}/images/test_known_image_empty_src/test_known_image_empty_src.html (100%) rename tests/data/{ => extractors}/images/test_known_image_empty_src/test_known_image_empty_src.json (100%) rename tests/data/{ => extractors}/images/test_known_image_name_parent/test_known_image_name_parent.html (100%) rename tests/data/{ => extractors}/images/test_known_image_name_parent/test_known_image_name_parent.json (100%) rename tests/data/{ => extractors}/images/test_opengraph_tag/test_opengraph_tag.html (100%) rename tests/data/{ => extractors}/images/test_opengraph_tag/test_opengraph_tag.json (100%) diff --git a/tests/data/images/test_basic_image/50850547cc7310bc53e30e802c6318f1 b/tests/data/extractors/images/test_basic_image/50850547cc7310bc53e30e802c6318f1 similarity index 100% rename from tests/data/images/test_basic_image/50850547cc7310bc53e30e802c6318f1 rename to tests/data/extractors/images/test_basic_image/50850547cc7310bc53e30e802c6318f1 diff --git a/tests/data/images/test_basic_image/test_basic_image.html b/tests/data/extractors/images/test_basic_image/test_basic_image.html similarity index 100% rename from tests/data/images/test_basic_image/test_basic_image.html rename to tests/data/extractors/images/test_basic_image/test_basic_image.html diff --git a/tests/data/images/test_basic_image/test_basic_image.json b/tests/data/extractors/images/test_basic_image/test_basic_image.json similarity index 100% rename from tests/data/images/test_basic_image/test_basic_image.json rename to tests/data/extractors/images/test_basic_image/test_basic_image.json diff --git a/tests/data/images/test_known_image_css_class/test_known_image_css_class.html b/tests/data/extractors/images/test_known_image_css_class/test_known_image_css_class.html similarity index 100% rename from tests/data/images/test_known_image_css_class/test_known_image_css_class.html rename to tests/data/extractors/images/test_known_image_css_class/test_known_image_css_class.html diff --git a/tests/data/images/test_known_image_css_class/test_known_image_css_class.json b/tests/data/extractors/images/test_known_image_css_class/test_known_image_css_class.json similarity index 100% rename from tests/data/images/test_known_image_css_class/test_known_image_css_class.json rename to tests/data/extractors/images/test_known_image_css_class/test_known_image_css_class.json diff --git a/tests/data/images/test_known_image_css_id/test_known_image_css_id.html b/tests/data/extractors/images/test_known_image_css_id/test_known_image_css_id.html similarity index 100% rename from tests/data/images/test_known_image_css_id/test_known_image_css_id.html rename to tests/data/extractors/images/test_known_image_css_id/test_known_image_css_id.html diff --git a/tests/data/images/test_known_image_css_id/test_known_image_css_id.json b/tests/data/extractors/images/test_known_image_css_id/test_known_image_css_id.json similarity index 100% rename from tests/data/images/test_known_image_css_id/test_known_image_css_id.json rename to tests/data/extractors/images/test_known_image_css_id/test_known_image_css_id.json diff --git a/tests/data/images/test_known_image_css_parent_class/test_known_image_css_parent_class.html b/tests/data/extractors/images/test_known_image_css_parent_class/test_known_image_css_parent_class.html similarity index 100% rename from tests/data/images/test_known_image_css_parent_class/test_known_image_css_parent_class.html rename to tests/data/extractors/images/test_known_image_css_parent_class/test_known_image_css_parent_class.html diff --git a/tests/data/images/test_known_image_css_parent_class/test_known_image_css_parent_class.json b/tests/data/extractors/images/test_known_image_css_parent_class/test_known_image_css_parent_class.json similarity index 100% rename from tests/data/images/test_known_image_css_parent_class/test_known_image_css_parent_class.json rename to tests/data/extractors/images/test_known_image_css_parent_class/test_known_image_css_parent_class.json diff --git a/tests/data/images/test_known_image_css_parent_id/test_known_image_css_parent_id.html b/tests/data/extractors/images/test_known_image_css_parent_id/test_known_image_css_parent_id.html similarity index 100% rename from tests/data/images/test_known_image_css_parent_id/test_known_image_css_parent_id.html rename to tests/data/extractors/images/test_known_image_css_parent_id/test_known_image_css_parent_id.html diff --git a/tests/data/images/test_known_image_css_parent_id/test_known_image_css_parent_id.json b/tests/data/extractors/images/test_known_image_css_parent_id/test_known_image_css_parent_id.json similarity index 100% rename from tests/data/images/test_known_image_css_parent_id/test_known_image_css_parent_id.json rename to tests/data/extractors/images/test_known_image_css_parent_id/test_known_image_css_parent_id.json diff --git a/tests/data/images/test_known_image_empty_src/test_known_image_empty_src.html b/tests/data/extractors/images/test_known_image_empty_src/test_known_image_empty_src.html similarity index 100% rename from tests/data/images/test_known_image_empty_src/test_known_image_empty_src.html rename to tests/data/extractors/images/test_known_image_empty_src/test_known_image_empty_src.html diff --git a/tests/data/images/test_known_image_empty_src/test_known_image_empty_src.json b/tests/data/extractors/images/test_known_image_empty_src/test_known_image_empty_src.json similarity index 100% rename from tests/data/images/test_known_image_empty_src/test_known_image_empty_src.json rename to tests/data/extractors/images/test_known_image_empty_src/test_known_image_empty_src.json diff --git a/tests/data/images/test_known_image_name_parent/test_known_image_name_parent.html b/tests/data/extractors/images/test_known_image_name_parent/test_known_image_name_parent.html similarity index 100% rename from tests/data/images/test_known_image_name_parent/test_known_image_name_parent.html rename to tests/data/extractors/images/test_known_image_name_parent/test_known_image_name_parent.html diff --git a/tests/data/images/test_known_image_name_parent/test_known_image_name_parent.json b/tests/data/extractors/images/test_known_image_name_parent/test_known_image_name_parent.json similarity index 100% rename from tests/data/images/test_known_image_name_parent/test_known_image_name_parent.json rename to tests/data/extractors/images/test_known_image_name_parent/test_known_image_name_parent.json diff --git a/tests/data/images/test_opengraph_tag/test_opengraph_tag.html b/tests/data/extractors/images/test_opengraph_tag/test_opengraph_tag.html similarity index 100% rename from tests/data/images/test_opengraph_tag/test_opengraph_tag.html rename to tests/data/extractors/images/test_opengraph_tag/test_opengraph_tag.html diff --git a/tests/data/images/test_opengraph_tag/test_opengraph_tag.json b/tests/data/extractors/images/test_opengraph_tag/test_opengraph_tag.json similarity index 100% rename from tests/data/images/test_opengraph_tag/test_opengraph_tag.json rename to tests/data/extractors/images/test_opengraph_tag/test_opengraph_tag.json diff --git a/tests/extractors/images.py b/tests/extractors/images.py index 582bca9f..e47a1dde 100644 --- a/tests/extractors/images.py +++ b/tests/extractors/images.py @@ -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() @@ -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) @@ -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) @@ -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,