Beispiel #1
0
    def test_retrieve_content_highlights_api(self):
        """Test retrieving a list of ContentHighlights"""
        ContentHighlight.objects.create(
            client=self.client,
            content=sample_content(
                client=self.client,
                title="Torre de belem 1",
                description="description Torre de belem 1",
            )
        )
        ContentHighlight.objects.create(
            client=self.client,
            content=sample_content(
                client=self.client,
                title="Torre de belem 2",
                description="description Torre de belem 2",
            )
        )

        res = self.api_client.get(CONTENT_HIGHLIGHTS_URL)
        content_highlights = ContentHighlight.objects.all()
        serializer = ContentHighlightSerializer(content_highlights, many=True)

        self.assertEqual(res.status_code, status.HTTP_200_OK)
        self.assertEqual(res.data, serializer.data)
Beispiel #2
0
    def test_retrieve_content_card_list(self):
        """Test retrieving a list of content cards"""
        client = sample_client()
        sample_content(client)
        sample_content(client=client,
                       title="Torre 2",
                       description="description torre 2")

        res = self.client.get(CONTENT_CARD_URL)
        content_cards = ContentCard.objects.all()
        serializer = ContentCardSerializer(content_cards, many=True)

        self.assertEqual(res.status_code, status.HTTP_200_OK)
        self.assertEqual(res.data, serializer.data)
Beispiel #3
0
    def test_retrieve_contents_api(self):
        """Test retrieving a list of contents"""
        client = sample_client()
        sample_content(client)
        sample_content(client,
                       title='Mosteiro1',
                       description='Mosteiro description')

        res = self.client.get(CONTENTS_URL)

        contents = Content.objects.all()
        serializer = ContentSerializer(contents, many=True)

        self.assertEqual(res.status_code, status.HTTP_200_OK)
        self.assertEqual(res.data, serializer.data)
Beispiel #4
0
    def test_view_content_detail(self):
        """Test viewing a content detail"""
        client = sample_client()
        content = sample_content(client)

        url = detail_url(content.uuid)
        res = self.client.get(url)

        serializer = ContentSerializer(content)
        self.assertEqual(res.data, serializer.data)
Beispiel #5
0
    def test_retrieve_upselling_card_list(self):
        """Test retrieving a list of upselling cards"""
        client = sample_client()
        content = sample_content(client)

        ContentUpselling.objects.create(client=client,
                                        content=content,
                                        title='ContentUpselling1')

        ContentUpselling.objects.create(client=client,
                                        content=sample_content(
                                            client=client,
                                            title="Praia 1",
                                            description="A melhor praia"),
                                        title='ContentUpselling2')

        res = self.client.get(UPSELLING_CARD_URL)
        upselling_cards = UpsellingCard.objects.all()
        serializer = UpsellingCardSerializer(upselling_cards, many=True)

        self.assertEqual(res.status_code, status.HTTP_200_OK)
        self.assertEqual(res.data, serializer.data)
Beispiel #6
0
    def test_retrieve_highlight_card_list(self):
        """Test retrieving a list of highlight cards"""
        client = sample_client()
        content = sample_content(client)

        ContentHighlight.objects.create(
            client=client,
            content=content,
        )

        ContentHighlight.objects.create(
            client=client,
            content=sample_content(
                client=client,
                title="Torre de belem 2",
                description="description Torre de belem 2",
            ))

        res = self.client.get(HIGHLIGHT_CARD_URL)
        highlight_card = HighlightCard.objects.all()
        serializer = HighlightCardSerializer(highlight_card, many=True)

        self.assertEqual(res.status_code, status.HTTP_200_OK)
        self.assertEqual(res.data, serializer.data)
    def test_retrieve_content_upselling_api(self):
        """Test retrieving a list of ContentUpselling"""
        ContentUpselling.objects.create(client=self.client,
                                        content=self.content,
                                        title='ContentUpselling1')
        ContentUpselling.objects.create(client=self.client,
                                        content=sample_content(
                                            client=self.client,
                                            title="Praia 1",
                                            description="A melhor praia"),
                                        title='ContentUpselling2')

        res = self.api_client.get(CONTENT_UPSELLING_URL)
        content_upselling = ContentUpselling.objects.all()
        serializer = ContentUpsellingSerializer(content_upselling, many=True)

        self.assertEqual(res.status_code, status.HTTP_200_OK)
        self.assertEqual(res.data, serializer.data)
Beispiel #8
0
 def setUp(self):
     self.api_client = APIClient()
     self.client = sample_client()
     self.content = sample_content(self.client)