Exemple #1
0
 def test_member_name(self):
     ce = CallbackEvent()
     self.assertEqual(ce.member_name, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(
         ce.member_name,
         ce.event_payload['action']['memberCreator']['fullName'])  # noqa
Exemple #2
0
 def test_card_name(self):
     ce = CallbackEvent()
     self.assertEqual(ce.card_name, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(
         ce.card_name,
         ce.event_payload['action']['data']['card']['name'])  # noqa
 def test_content_type(self):
     ce = CallbackEvent()
     self.assertEqual(ce.content_type, None)
     ce.event_payload = get_sample_data('addAttachmentToCard', 'text')
     ce.event_type = 'addAttachmentToCard'
     ce.resolve_content_type()
     self.assertEqual(ce.content_type, ce.event_payload['action']['data']
                      ['attachment']['content_type'])  # noqa
Exemple #4
0
 def test_post_200(self):
     Webhook(
         auth_token=self.payload['auth_token'],
         trello_model_id=self.payload['trello_model_id']).save(sync=False)
     self.assertEqual(CallbackEvent.objects.count(), 0)
     test_payload = get_sample_data('commentCard', 'json')
     resp = self.client.post(self.url,
                             data=json.dumps(test_payload),
                             content_type='application/json')
     self.assertEqual(resp.status_code, 200)
     self.assertEqual(CallbackEvent.objects.count(), 1)
     self.assertEqual(CallbackEvent.objects.get().event_payload,
                      test_payload)
 def test_post_200(self):
     Webhook(
         auth_token=self.payload['auth_token'],
         trello_model_id=self.payload['trello_model_id']
     ).save(sync=False)
     self.assertEqual(CallbackEvent.objects.count(), 0)
     test_payload = get_sample_data('commentCard', 'json')
     resp = self.client.post(
         self.url,
         data=json.dumps(test_payload),
         content_type='application/json'
     )
     self.assertEqual(resp.status_code, 200)
     self.assertEqual(CallbackEvent.objects.count(), 1)
     self.assertEqual(
         CallbackEvent.objects.get().event_payload,
         test_payload
     )
 def test_card_name(self):
     ce = CallbackEvent()
     self.assertEqual(ce.card_name, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(ce.card_name, ce.event_payload['action']['data']['card']['name'])  # noqa
 def test_member_name(self):
     ce = CallbackEvent()
     self.assertEqual(ce.member_name, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(ce.member_name, ce.event_payload['action']['memberCreator']['fullName'])  # noqa
 def test_list(self):
     ce = CallbackEvent()
     self.assertEqual(ce.list, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(ce.list, ce.event_payload['action']['data']['list'])
 def test_member(self):
     ce = CallbackEvent()
     self.assertEqual(ce.action_data, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(ce.member, ce.event_payload['action']['memberCreator'])
 def test_add_callback(self):
     hook = Webhook().save(sync=False)
     payload = get_sample_data('commentCard', 'json')
     event = hook.add_callback(json.dumps(payload))
     self.assertEqual(event.webhook, hook)
     self.assertEqual(event.event_payload, payload)
Exemple #11
0
 def test_list(self):
     ce = CallbackEvent()
     self.assertEqual(ce.list, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(ce.list, ce.event_payload['action']['data']['list'])
Exemple #12
0
 def test_member(self):
     ce = CallbackEvent()
     self.assertEqual(ce.action_data, None)
     ce.event_payload = get_sample_data('createCard', 'text')
     self.assertEqual(ce.member,
                      ce.event_payload['action']['memberCreator'])
Exemple #13
0
 def test_add_callback(self):
     hook = Webhook().save(sync=False)
     payload = get_sample_data('commentCard', 'json')
     event = hook.add_callback(json.dumps(payload))
     self.assertEqual(event.webhook, hook)
     self.assertEqual(event.event_payload, payload)
Exemple #14
0
 def test_resolve_content_type(self):
     ce = CallbackEvent()
     ce.event_payload = get_sample_data('addAttachmentToCard', 'text')
     ce.event_type = 'addAttachmentToCard'
     ce.resolve_content_type()
     self.assertEqual(ce.content_type, "image/jpeg")