Permalink
Browse files

Fix issue #56. updated the test suite to reflect changes in the proje…

…ct. minor changes to html_diff and data_aggregator
  • Loading branch information...
1 parent 9e6a9e6 commit 8b58b33cddbace2ba38e7c7d6fa3414b29541455 @maurodoglio maurodoglio committed Mar 26, 2013
@@ -25,7 +25,7 @@ def test_instantiation():
assert ua.ua_type == BatchUserAgent.MOBILE
assert ua.ua_type != BatchUserAgent.DESKTOP
assert ua.ua_string == 'Mozilla / 5.0'
- assert unicode(ua) == u"(mobile) Mozilla / 5.0"
+ assert unicode(ua) == u"Mozilla / 5.0"
def test_length_toolong():
@@ -8,10 +8,16 @@
from spade.model.models import UserAgent
-def test_unicode():
+def test_unicode_human_name():
"""Unicode representation of a user agent is the UA string."""
ua = UserAgent(ua_string=u"Mozilla/5.0", ua_human_name=u"Moz 5")
- assert unicode(ua) == u"(desktop) Moz 5: 'Mozilla/5.0'"
+ assert unicode(ua) == u"Moz 5"
+
+
+def test_unicode_ua_string():
+ """Unicode representation of a user agent is the UA string."""
+ ua = UserAgent(ua_string=u"Mozilla/5.0",)
+ assert unicode(ua) == u"Mozilla/5.0"
def test_length_toolong():
@@ -86,6 +86,7 @@ def generate_offsite_testing_requests():
mock_request.meta['referrer'] = 'http://test.com'
yield mock_request
+
def generate_crawl_html_requests():
"""Generate an arbitrary request"""
mock_request = Request('http://test.com/hello.html')
@@ -168,9 +169,10 @@ def test_crawl_limit(spider, depth_middleware, mock_response, depth2_request):
# Assert no requests went through
assert len(results) == 0
+
def test_linkedpages(spider, depth_middleware, mock_response, depth2_request):
"""
- Ensure all CSS/JS requests are not filtered when linked from level 2 html
+ Ensure only JS requests are not filtered when linked from level 2 html
pages
"""
request_generator = generate_crawl_js_and_css_requests()
@@ -184,5 +186,4 @@ def test_linkedpages(spider, depth_middleware, mock_response, depth2_request):
for req in remaining_requests:
results.append(req)
- # Assert both requests went through
- assert len(results) == 2
+ assert len(results) == 1
@@ -259,15 +259,9 @@ def test_css_item_emission(spider, linked_css_request, css_headers, mock_css):
item_expected['urlscan'] = mock_urlscan
item_expected['url'] = mock_response.url
item_expected['user_agent'] = mock_response.meta['user_agent']
+ item_expected['redirected_from'] = ''
- item_collected = None
- for item in pipeline_generator:
- if isinstance(item, MarkupItem):
- item_collected = item
- else:
- assert False
-
- assert item_expected == item_collected
+ assert list(pipeline_generator) == [item_expected]
def test_js_item_emission(spider, linked_js_request, js_headers, mock_js):
@@ -303,12 +297,6 @@ def test_js_item_emission(spider, linked_js_request, js_headers, mock_js):
item_expected['urlscan'] = mock_urlscan
item_expected['url'] = mock_response.url
item_expected['user_agent'] = mock_response.meta['user_agent']
+ item_expected['redirected_from'] = ''
- item_collected = None
- for item in pipeline_generator:
- if isinstance(item, MarkupItem):
- item_collected = item
- else:
- assert False
-
- assert item_expected == item_collected
+ assert list(pipeline_generator) == [item_expected]
Oops, something went wrong.

0 comments on commit 8b58b33

Please sign in to comment.