Exemplo n.º 1
0
    def test_action_wrong_data_returned(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action('+8952342343',
                                    'tests.test_main.wrong_data_return',
                                    generate_code_func=gen_func)

        with self.assertRaises(exceptions.WrongDataReturned):
            main.apply_action(action_pk, '2048')
Exemplo n.º 2
0
    def test_action_system_fault(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action('*****@*****.**',
                                    'tests.test_main.system_fault',
                                    generate_code_func=gen_func)

        with self.assertRaises(exceptions.SystemFaultError):
            main.apply_action(action_pk, '2048')
Exemplo n.º 3
0
    def test_cant_find_action(self):
        main.set_action(
            '*****@*****.**',
            'tests.test_main.simple_action',
        )

        with self.assertRaises(exceptions.CantFindAction):
            main.apply_action(4096, '2048')
Exemplo n.º 4
0
    def test_cant_find_action(self):
        main.set_action(
            '*****@*****.**',
            'tests.test_main.simple_action',
        )

        with self.assertRaises(exceptions.CantFindAction):
            main.apply_action(4096, '2048')
Exemplo n.º 5
0
    def test_action_error_during_process(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action('*****@*****.**',
                                    'tests.test_main.error_during_process',
                                    generate_code_func=gen_func)

        with self.assertRaises(exceptions.ErrorDuringProcess):
            main.apply_action(action_pk, '2048')
Exemplo n.º 6
0
    def test_wrong_code(self):
        action_pk = main.set_action('*****@*****.**',
                                    'tests.test_main.simple_action', {
                                        'param_first': 'test',
                                        'param_second': 'param'
                                    })

        with self.assertRaises(exceptions.WrongCode):
            main.apply_action(action_pk, '3482332')
Exemplo n.º 7
0
 def test_wrong_scope(self):
     action_pk = main.set_action(
         '*****@*****.**',
         'tests.test_main.simple_action',
         {'param_first': 1, 'param_second': 2},
         scope='scope1',
         generate_code_func=lambda: '2048'
     )
     with self.assertRaises(exceptions.WrongScopeException):
         main.apply_action(action_pk, '2048', scope='scope2')
Exemplo n.º 8
0
    def test_action_wrong_data_returned(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action(
            '+8952342343',
            'tests.test_main.wrong_data_return',
            generate_code_func=gen_func
        )

        with self.assertRaises(exceptions.WrongDataReturned):
            main.apply_action(action_pk, '2048')
Exemplo n.º 9
0
    def test_action_system_fault(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action(
            '*****@*****.**',
            'tests.test_main.system_fault',
            generate_code_func=gen_func
        )

        with self.assertRaises(exceptions.SystemFaultError):
            main.apply_action(action_pk, '2048')
Exemplo n.º 10
0
    def test_action_error_during_process(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action(
            '*****@*****.**',
            'tests.test_main.error_during_process',
            generate_code_func=gen_func
        )

        with self.assertRaises(exceptions.ErrorDuringProcess):
            main.apply_action(action_pk, '2048')
Exemplo n.º 11
0
 def test_wrong_scope(self):
     action_pk = main.set_action('*****@*****.**',
                                 'tests.test_main.simple_action', {
                                     'param_first': 1,
                                     'param_second': 2
                                 },
                                 scope='scope1',
                                 generate_code_func=lambda: '2048')
     with self.assertRaises(exceptions.WrongScopeException):
         main.apply_action(action_pk, '2048', scope='scope2')
Exemplo n.º 12
0
    def test_wrong_code(self):
        action_pk = main.set_action(
            '*****@*****.**',
            'tests.test_main.simple_action',
            {
                'param_first': 'test',
                'param_second': 'param'
            }
        )

        with self.assertRaises(exceptions.WrongCode):
            main.apply_action(action_pk, '3482332')
Exemplo n.º 13
0
    def test_used_code(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action('*****@*****.**',
                                    'tests.test_main.simple_action', {
                                        'param_first': 'test',
                                        'param_second': 'param'
                                    },
                                    generate_code_func=gen_func)

        main.apply_action(action_pk, '2048')

        with self.assertRaises(exceptions.UsedAction):
            main.apply_action(action_pk, '2048')
Exemplo n.º 14
0
    def test_out_of_date(self):
        gen_func = lambda: '2048'

        action_pk = main.set_action('*****@*****.**',
                                    'tests.test_main.simple_action', {
                                        'param_first': 'test',
                                        'param_second': 'param'
                                    },
                                    generate_code_func=gen_func,
                                    send_code_func=lambda *args: True)

        with mock.patch('confirmaction.models.Action.is_actual') as mock_meth:
            mock_meth.return_value = False
            with self.assertRaises(exceptions.OutOfDate):
                main.apply_action(action_pk, '2048')
Exemplo n.º 15
0
    def test_used_code(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action(
            '*****@*****.**',
            'tests.test_main.simple_action',
            {
                'param_first': 'test',
                'param_second': 'param'
            },
            generate_code_func=gen_func
        )

        main.apply_action(action_pk, '2048')

        with self.assertRaises(exceptions.UsedAction):
            main.apply_action(action_pk, '2048')
Exemplo n.º 16
0
 def test_all_ok_with_scope(self):
     action_pk = main.set_action('*****@*****.**',
                                 'tests.test_main.simple_action', {
                                     'param_first': 1,
                                     'param_second': 2
                                 },
                                 scope='scope1',
                                 generate_code_func=lambda: '2048')
     result = main.apply_action(action_pk, '2048', scope='scope1')
Exemplo n.º 17
0
    def test_out_of_date(self):
        gen_func = lambda: '2048'

        action_pk = main.set_action(
            '*****@*****.**',
            'tests.test_main.simple_action',
            {
                'param_first': 'test',
                'param_second': 'param'
            },
            generate_code_func=gen_func,
            send_code_func=lambda *args: True
        )

        with mock.patch('confirmaction.models.Action.is_actual') as mock_meth:
            mock_meth.return_value = False
            with self.assertRaises(exceptions.OutOfDate):
                main.apply_action(action_pk, '2048')
Exemplo n.º 18
0
 def test_all_ok_with_scope(self):
     action_pk = main.set_action(
         '*****@*****.**',
         'tests.test_main.simple_action',
         {'param_first': 1, 'param_second': 2},
         scope='scope1',
         generate_code_func=lambda: '2048'
     )
     result = main.apply_action(action_pk, '2048', scope='scope1')
Exemplo n.º 19
0
    def test_action_done(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action('*****@*****.**',
                                    'tests.test_main.simple_action', {
                                        'param_first': 'test',
                                        'param_second': 'param'
                                    },
                                    generate_code_func=gen_func)

        data = main.apply_action(action_pk, '2048')
        self.assertIn('status', data)
Exemplo n.º 20
0
    def test_action_done(self):
        gen_func = lambda: '2048'
        action_pk = main.set_action(
            '*****@*****.**',
            'tests.test_main.simple_action',
            {
                'param_first': 'test',
                'param_second': 'param'
            },
            generate_code_func=gen_func
        )

        data = main.apply_action(action_pk, '2048')
        self.assertIn('status', data)