Esempio n. 1
0
 def test_create(self):
     country = Country_factory.build()
     serializer = Country_serializer(country)
     data = serializer.data
     serializer = Country_serializer(data=data)
     is_valid = serializer.is_valid()
     self.assertTrue(is_valid, serializer.errors)
     country_result = serializer.save()
     self.assertTrue(isinstance(country_result, Country_model))
Esempio n. 2
0
 def test_validate(self, country_nested_filter):
     exists = MagicMock()
     exists.exists.return_value = True
     country_nested_filter.return_value = exists
     country = Country_factory.build()
     serializer = Country_nested_serializer(country)
     data = serializer.data
     serializer = Country_nested_serializer(data=data)
     is_valid = serializer.is_valid()
     self.assertTrue(is_valid, serializer.errors)
Esempio n. 3
0
    def test_validate_fail(self, country_nested_filter):
        """
		Prueba para cuando el pais no existe en la base de datos
		deberia de regresar el serializar no deberia de ser valido
		"""
        exists = MagicMock()
        exists.exists.return_value = False
        country_nested_filter.return_value = exists
        country = Country_factory.build()
        serializer = Country_nested_serializer(country)
        data = serializer.data
        serializer = Country_nested_serializer(data=data)
        is_valid = serializer.is_valid()
        self.assertFalse(is_valid, "deberia de regresar el error que no existe" " en el iso en la base de datos")