def test_basic(self): poll = PollFactory.create() data = { 'locale': 'es', 'platform': 'Windows 8.1', 'product': 'Firefox', 'version': '30.0', 'channel': 'stable', 'poll': poll.slug, 'answer': '0' } resp = self.client.post( reverse('heartbeat-api'), content_type='application/json', data=json.dumps(data)) eq_(resp.status_code, 201) ans = Answer.objects.latest('id') eq_(ans.locale, 'es') eq_(ans.platform, 'Windows 8.1') eq_(ans.product, 'Firefox') eq_(ans.version, '30.0') eq_(ans.channel, 'stable') eq_(ans.answer, '0')
def test_disabled_poll(self): poll = PollFactory.create(enabled=False) data = { "locale": "es", "platform": "Windows 8.1", "product": "Firefox", "version": "30.0", "channel": "stable", "poll": poll.slug, "answer": "0", } resp = self.client.post(reverse("heartbeat-api"), content_type="application/json", data=json.dumps(data)) eq_(resp.status_code, 400) eq_(resp.content, '{"msg": "poll \\"firefox-is-great\\" is not currently running"}')
def test_disabled_poll(self): poll = PollFactory.create(enabled=False) data = { 'locale': 'es', 'platform': 'Windows 8.1', 'product': 'Firefox', 'version': '30.0', 'channel': 'stable', 'poll': poll.slug, 'answer': '0' } resp = self.client.post( reverse('heartbeat-api'), content_type='application/json', data=json.dumps(data)) eq_(resp.status_code, 400) eq_(resp.content, '{"msg": "poll \\"firefox-is-great\\" is not currently running"}')
def test_basic(self): poll = PollFactory.create() data = { "locale": "es", "platform": "Windows 8.1", "product": "Firefox", "version": "30.0", "channel": "stable", "poll": poll.slug, "answer": "0", } resp = self.client.post(reverse("heartbeat-api"), content_type="application/json", data=json.dumps(data)) eq_(resp.status_code, 201) ans = Answer.objects.latest("id") eq_(ans.locale, "es") eq_(ans.platform, "Windows 8.1") eq_(ans.product, "Firefox") eq_(ans.version, "30.0") eq_(ans.channel, "stable") eq_(ans.answer, "0")