Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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')
Esempio 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)
Esempio 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)