addons-server/apps/discovery/tests.py

48 строки
1.4 KiB
Python
Исходник Обычный вид История

2010-05-03 22:31:37 +04:00
import json
from django import test
from nose.tools import eq_
import test_utils
from amo.urlresolvers import reverse
from addons.models import Addon
2010-05-03 22:42:36 +04:00
from discovery.views import get_addon_ids
2010-05-03 22:31:37 +04:00
class RecsTest(test_utils.TestCase):
fixtures = ['base/addons', 'base/category', 'base/featured']
@classmethod
def setup_class(cls):
test.Client().get('/')
def setUp(self):
self.url = reverse('discovery.recs')
self.guids = ["bettergcal@ginatrapani.org",
"firebug@software.joehewitt.com",
"foxyproxy@eric.h.jung",
"isreaditlater@ideashower.com",
2010-05-03 22:42:36 +04:00
"not-a-real-guid",
2010-05-03 22:31:37 +04:00
"yslow@yahoo-inc.com"]
self.json = json.dumps(self.guids)
def test_get(self):
"""GET should find method not allowed."""
response = self.client.get(self.url)
eq_(response.status_code, 405)
2010-05-03 22:34:30 +04:00
def test_empty_post_data(self):
response = self.client.post(self.url)
eq_(response.status_code, 400)
def test_bad_post_data(self):
response = self.client.post(self.url, "{]{",
content_type='application/json')
eq_(response.status_code, 400)
2010-05-03 22:42:36 +04:00
def test_get_addon_ids(self):
ids = get_addon_ids(self.guids)
expected = [5299, 1843, 2464, 7661, 5369]
eq_(set(ids), set(expected))