Skip to content

Commit

Permalink
small tweaks to Video tests
Browse files Browse the repository at this point in the history
* don't depend on nose
* don't actually scrape the Video
  • Loading branch information
paulswartz committed Apr 5, 2012
1 parent 0bd0821 commit ced9966
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions vidscraper/tests/unit/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,32 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import unittest
import json

from nose.tools import eq_

from vidscraper import auto_scrape
from vidscraper.compat import json
from vidscraper.suites.base import Video
from vidscraper.videos import Video


class VideoTestCase(unittest.TestCase):
def test_items(self):
video = auto_scrape("http://www.youtube.com/watch?v=J_DV9b0x7v4")
video = Video("http://www.youtube.com/watch?v=J_DV9b0x7v4")

# Make sure items can be iterated over and that there's one
# for every field.
for i, item in enumerate(video.items()):
eq_(item[0], Video._all_fields[i])
self.assertEqual(item[0], Video._all_fields[i])

def test_items_with_fields(self):
fields = ['title', 'user']
video = auto_scrape("http://www.youtube.com/watch?v=J_DV9b0x7v4",
fields)
video = Video("http://www.youtube.com/watch?v=J_DV9b0x7v4",
fields=fields)

# Make sure items can be iterated over and that there's one
# for every field.
for i, item in enumerate(video.items()):
eq_(item[0], fields[i])
self.assertEqual(item[0], fields[i])

def test_to_json(self):
video = auto_scrape("http://www.youtube.com/watch?v=J_DV9b0x7v4")
video = Video("http://www.youtube.com/watch?v=J_DV9b0x7v4")

This comment has been minimized.

Copy link
@willkg

willkg Apr 5, 2012

Contributor

You can't do this one. You need real data in order to make sure it jsonifies correctly.

This comment has been minimized.

Copy link
@paulswartz

paulswartz Apr 5, 2012

Author Contributor

Good catch; I'll use some of the data we have in other test cases.


data_json = video.to_json()
# Verify that we can load the json back into Python.
Expand Down

0 comments on commit ced9966

Please sign in to comment.