示例#1
0
文件: api.py 项目: anukat2015/opal-1
 def update(self, request, episode):
     if 'id' in request.data:
         del request.data['id']
     tag_names = [n for n, v in request.data.items() if v]
     pre = episode.to_dict(request.user)
     episode.set_tag_names(tag_names, request.user)
     post = episode.to_dict(request.user)
     glossolalia.transfer(pre, post)
     return Response(episode.tagging_dict(request.user)[0], status=status.HTTP_202_ACCEPTED)
示例#2
0
文件: api.py 项目: wjt/opal
 def update(self, request, episode):
     if 'id' in request.data:
         del request.data['id']
     tag_names = [n for n, v in request.data.items() if v]
     pre = episode.to_dict(request.user)
     episode.set_tag_names(tag_names, request.user)
     post = episode.to_dict(request.user)
     glossolalia.transfer(pre, post)
     return Response(episode.tagging_dict(request.user)[0],
                     status=status.HTTP_202_ACCEPTED)
示例#3
0
 def test_transfer_calls_send_upstream(self, sender):
     with patch('opal.core.glossolalia.INTEGRATING', new=True):
         transfer = glossolalia.transfer({}, {'foo': 'bar'})
         self.assertEqual('transfer', sender.call_args[0][0])
         self.assertEqual(
             'bar',
             json.loads(sender.call_args[0][1]['data'])['post']['foo'])
示例#4
0
 def test_transfer_not_integratng(self, sender):
     with patch('opal.core.glossolalia.INTEGRATING', new=False):
         transfer = glossolalia.transfer(None, None)
         self.assertEqual(
             None, transfer)  # Mostly a proxy for "Does this stacktrace?"
         self.assertFalse(sender.called)
 def test_transfer_calls_send_upstream(self, sender):
     with patch('opal.core.glossolalia.INTEGRATING', new=True):
         transfer = glossolalia.transfer({}, {'foo': 'bar'})
         self.assertEqual('transfer', sender.call_args[0][0])
         self.assertEqual('bar', json.loads(sender.call_args[0][1]['data'])['post']['foo'])
 def test_transfer_not_integratng(self, sender):
     with patch('opal.core.glossolalia.INTEGRATING', new=False):
         transfer = glossolalia.transfer(None, None)
         self.assertEqual(None, transfer) # Mostly a proxy for "Does this stacktrace?"
         self.assertFalse(sender.called)