Example #1
0
    def test_validate_raise_false(self):
        instance = ZoopObjectFactory(id=1)
        self.assertIsInstance(instance, ZoopObject)

        instance.id = None

        instance.validate_fields(raise_exception=False)
Example #2
0
    def test_validate_raise(self):
        instance = ZoopObjectFactory(id=1)
        self.assertIsInstance(instance, ZoopObject)

        instance.id = None

        self.assertRaises(ValidationError, instance.validate_fields)
Example #3
0
    def test_get_original_fields_mapping(self):
        instance: ZoopObject = ZoopObjectFactory(id=1)

        expected = {"modificado": "original"}

        result = instance.get_original_different_fields_mapping()

        self.assertEqual(expected, result)
Example #4
0
    def test_validate_custom_fields(self):
        """
        Dado que existe um zoopObject z1
        Quando for chamado z1.custom_validate_fields()
        Então deve ser retornado uma lista vazia
        """
        z1: ZoopObject = ZoopObjectFactory(id=1)

        expected = []

        result = z1.validate_custom_fields()

        self.assertEqual(expected, result)
Example #5
0
    def test_validate_call_validate_custom_fields(self):
        """
        Dado que existe um zoopObject z1
        Quando for chamado z1.validate_fields()
        Então z1.validate_custom_fields() deve ter sido chamado
        """
        z1: ZoopObject = ZoopObjectFactory(id=1)

        with patch("zoop_wrapper.models.base.ZoopObject.validate_custom_fields"
                   ) as mocked_validate:
            z1.validate_fields()

            self.assertIsInstance(mocked_validate, MagicMock)
            mocked_validate.assert_called_once_with()
Example #6
0
 def test_create_allow_empty(self):
     instance = ZoopObjectFactory(allow_empty=True)
     self.assertIsInstance(instance, ZoopObject)
Example #7
0
 def test_create(self):
     instance = ZoopObjectFactory(id=1)
     self.assertIsInstance(instance, ZoopObject)
Example #8
0
 def test_init_call_init_custom_values(self, mocked_init_custom_fields):
     ZoopObjectFactory(id=1)
     mocked_init_custom_fields.assert_called_once()
Example #9
0
 def test_init_call_validate(self, mocked_validate):
     ZoopObjectFactory(id=1)
     mocked_validate.assert_called_once()
Example #10
0
    def test_validate_allow_empty(self):
        instance = ZoopObjectFactory(allow_empty=True)
        self.assertIsInstance(instance, ZoopObject)

        instance.validate_fields()