Exemple #1
0
 def confirmation(self, value):
     if isinstance(value, dict):
         self.__confirmation = ConfirmationFactory().create(value, self.context())
     elif isinstance(value, Confirmation):
         self.__confirmation = value
     else:
         raise TypeError('Invalid confirmation type')
Exemple #2
0
    def test_factory_method(self):
        req_redirect_instance = ConfirmationFactory().create(
            {'type': ConfirmationType.REDIRECT}, DataContext.REQUEST)
        self.assertIsInstance(req_redirect_instance,
                              RequestConfirmationRedirect)

        req_external_instance = ConfirmationFactory().create(
            {'type': ConfirmationType.EXTERNAL}, DataContext.REQUEST)
        self.assertIsInstance(req_external_instance,
                              RequestConfirmationExternal)

        res_redirect_instance = ConfirmationFactory().create(
            {'type': ConfirmationType.REDIRECT}, DataContext.RESPONSE)
        self.assertIsInstance(res_redirect_instance,
                              ResponseConfirmationRedirect)

        res_external_instance = ConfirmationFactory().create(
            {'type': ConfirmationType.EXTERNAL}, DataContext.RESPONSE)
        self.assertIsInstance(res_external_instance,
                              ResponseConfirmationExternal)
 def confirmation(self, value):
     self.__confirmation = ConfirmationFactory().create(
         value, self.context())