def test_submission_action_attributes(self):
        serializer = ActionSerializer(self.comment_action)
        serializer.context = {'request': RequestFactory().get('')}

        self.assertIn('id', serializer.data)
        self.assertEqual(serializer.data.get('action'), 'create')
        self.assertEqual(serializer.data.get('target_type'), 'comments')
        self.assertIn('target', serializer.data)
        self.assertNotIn('thing', serializer.data)
示例#2
0
    def test_submission_action_attributes(self):
        serializer = ActionSerializer(self.comment_action)
        serializer.context = {"request": RequestFactory().get("")}

        self.assertIn("id", serializer.data)
        self.assertEqual(serializer.data.get("action"), "create")
        self.assertEqual(serializer.data.get("target_type"), "comments")
        self.assertIn("target", serializer.data)
        self.assertNotIn("thing", serializer.data)
    def test_submission_action_attributes(self):
        serializer = ActionSerializer(self.comment_action)
        serializer.context = {
            'request': RequestFactory().get('')
        }

        self.assertIn('id', serializer.data)
        self.assertEqual(serializer.data.get('action'), 'create')
        self.assertEqual(serializer.data.get('target_type'), 'comments')
        self.assertIn('target', serializer.data)
        self.assertNotIn('thing', serializer.data)
    def test_prejoined_submission_action_attributes(self):
        action = Action.objects.all()\
            .select_related('thing__place' ,'thing__submission')\
            .filter(thing=self.comment_action.thing)[0]

        serializer = ActionSerializer(action)
        serializer.context = {'request': RequestFactory().get('')}

        self.assertIn('id', serializer.data)
        self.assertEqual(serializer.data.get('action'), 'create')
        self.assertEqual(serializer.data.get('target_type'), 'comments')
        self.assertIn('target', serializer.data)
        self.assertNotIn('thing', serializer.data)
    def test_prejoined_submission_action_attributes(self):
        action = Action.objects.all()\
            .select_related('thing__place' ,'thing__submission')\
            .filter(thing=self.comment_action.thing)[0]

        serializer = ActionSerializer(action)
        serializer.context = {
            'request': RequestFactory().get('')
        }

        self.assertIn('id', serializer.data)
        self.assertEqual(serializer.data.get('action'), 'create')
        self.assertEqual(serializer.data.get('target_type'), 'comments')
        self.assertIn('target', serializer.data)
        self.assertNotIn('thing', serializer.data)
示例#6
0
    def test_prejoined_submission_action_attributes(self):
        action = (
            Action.objects.all()
            .select_related("thing__place", "thing__submission")
            .filter(thing=self.comment_action.thing)[0]
        )

        serializer = ActionSerializer(action)
        serializer.context = {"request": RequestFactory().get("")}

        self.assertIn("id", serializer.data)
        self.assertEqual(serializer.data.get("action"), "create")
        self.assertEqual(serializer.data.get("target_type"), "comments")
        self.assertIn("target", serializer.data)
        self.assertNotIn("thing", serializer.data)
    def test_place_action_attributes(self):
        serializer = ActionSerializer(
            self.place_action, context={'request': RequestFactory().get('')})

        self.assertIn('id', serializer.data)
        self.assertEqual(serializer.data.get('action'), 'create')
        self.assertEqual(serializer.data.get('target_type'), 'place')
        self.assertIn('target', serializer.data)
        self.assertNotIn('thing', serializer.data)