Exemplo n.º 1
0
    def test_post_portfolios_with_filetype(self):
        url = reverse('api:portfolios-detail',
                      kwargs={
                          'slug': self.perfil.slug,
                          'type': "file"
                      })

        fake_file = file.dummy_base64_file()

        data = {"nome": "Arquivo de Teste", "conteudo": fake_file}

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 2
0
    def test_post_porffolio_with_image(self):
        url = reverse('api:portfolios-detail',
                      kwargs={
                          'slug': self.perfil.slug,
                          'type': "image"
                      })

        fake_image = file.dummy_base64_file(format="png")

        data = {"descricao": "Nome da Imagem", "conteudo": fake_image}

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 3
0
    def test_post_porffolio_with_image(self):
        url = reverse('api:portfolios-detail',
                      kwargs={'slug': self.perfil.slug, 'type': "image"})

        fake_image = file.dummy_base64_file(format="png")

        data = {
            "descricao": "Nome da Imagem",
            "conteudo": fake_image
        }

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 4
0
    def test_post_portfolios_with_filetype(self):
        url = reverse('api:portfolios-detail',
                      kwargs={'slug': self.perfil.slug, 'type': "file"})

        fake_file = file.dummy_base64_file()

        data = {
            "nome": "Arquivo de Teste",
            "conteudo": fake_file
        }

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 5
0
    def test_should_post_documents_to_ente_or_profile(self):
        url = reverse('api:documents')

        fake_file = file.dummy_base64_file()

        data = {
            "dono": self.ente.id_pub,
            "nome": "Arquivo de Teste",
            "vencimento": "01/03/2015",
            "conteudo": fake_file
        }

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 6
0
    def test_post_portfolio_with_audio(self):
        url = reverse('api:portfolios-detail',
                      kwargs={
                          'slug': self.perfil.slug,
                          'type': "audio"
                      })

        fake_audio = file.dummy_base64_file(format="mp3",
                                            content_type="audio/mp3")

        data = {"nome": "Nome do Audio", "conteudo": fake_audio}

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 7
0
    def test_should_post_documents_to_ente_or_profile(self):
        url = reverse('api:documents')

        fake_file = file.dummy_base64_file()

        data = {
            "dono": self.ente.id_pub,
            "nome": "Arquivo de Teste",
            "vencimento": "01/03/2015",
            "conteudo": fake_file
        }

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 8
0
    def test_post_portfolio_with_audio(self):
        url = reverse('api:portfolios-detail',
                      kwargs={'slug': self.perfil.slug, 'type': "audio"})

        fake_audio = file.dummy_base64_file(format="mp3",
                                            content_type="audio/mp3")

        data = {
            "nome": "Nome do Audio",
            "conteudo": fake_audio
        }

        response = self.client.post(url, data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Exemplo n.º 9
0
    def test_should_delete_documents(self):
        url = reverse('api:documents')

        fake_file = file.dummy_base64_file()

        data = {
            "dono": self.ente.id_pub,
            "nome": "Arquivo de Teste",
            "vencimento": "01/03/2015",
            "conteudo": fake_file
        }

        response = self.client.post(url, data, format='json')

        document = Documento.objects.filter(nome__icontains="Arquivo de Teste")[0]
        url = reverse('api:documents-detail', kwargs={'uid': document.id_pub})
        response = self.client.delete(url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
Exemplo n.º 10
0
    def test_should_delete_documents(self):
        url = reverse('api:documents')

        fake_file = file.dummy_base64_file()

        data = {
            "dono": self.ente.id_pub,
            "nome": "Arquivo de Teste",
            "vencimento": "01/03/2015",
            "conteudo": fake_file
        }

        response = self.client.post(url, data, format='json')

        document = Documento.objects.filter(
            nome__icontains="Arquivo de Teste")[0]
        url = reverse('api:documents-detail', kwargs={'uid': document.id_pub})
        response = self.client.delete(url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)