Esempio n. 1
0
def primitive_rejected_wrapper(primitive_value):
    def test_method(test_case, promise, done):

        def return_primitive(value):
            return primitive_value

        def retrieve_primitive(value):
            test_case.assertEqual(value, primitive_value)
            done()

        promise.then(None, return_primitive).then(retrieve_primitive)

    return test_method

None_FulfilledTestCase = generate_fulfilled_test_case(primitive_fulfilled_wrapper(None), dummy,
                                                      module=__name__,
                                                      name='None_FulfilledTestCase')
Zero_FulfilledTestCase = generate_fulfilled_test_case(primitive_fulfilled_wrapper(0), dummy,
                                                      module=__name__,
                                                      name='Zero_FulfilledTestCase')
One_FulfilledTestCase = generate_fulfilled_test_case(primitive_fulfilled_wrapper(1), dummy,
                                                     module=__name__,
                                                     name='One_FulfilledTestCase')
String_FulfilledTestCase = generate_fulfilled_test_case(primitive_fulfilled_wrapper('asdf'), dummy,
                                                        module=__name__,
                                                        name='String_FulfilledTestCase')
EmptyString_FulfilledTestCase = generate_fulfilled_test_case(primitive_fulfilled_wrapper(''), dummy,
                                                             module=__name__,
                                                             name='EmptyString_FulfilledTestCase')
List_FulfilledTestCase = generate_fulfilled_test_case(primitive_fulfilled_wrapper(['asdf', 'value1']), dummy,
                                                      module=__name__,
Esempio n. 2
0
    promise2 = promise.then()
    promise2.then(promise2_handler)


def on_rejected_not_a_function_pass_through(test_case, promise, done):

    def promise2_handler(value):
        test_case.assertIs(value, sentinel)
        done()

    promise2 = promise.then()
    promise2.then(None, promise2_handler)

FulfilledThrowsExceptionPromise = generate_fulfilled_test_case(method=on_fulfilled_throws_exception_promise_is_rejected,
                                                               value=dict(),
                                                               module=__name__,
                                                               name='FulfilledThrowsExceptionPromise')
RejectedThrowsExceptionPromise = generate_rejected_test_case(method=on_rejected_throws_exception_promise_is_rejected,
                                                             value=dict(),
                                                             module=__name__,
                                                             name='RejectedThrowsExceptionPromise')
FulfilledPassThrough = generate_fulfilled_test_case(method=on_fulfilled_not_a_function_pass_through,
                                                    value=sentinel,
                                                    module=__name__,
                                                    name='FulfilledPassThrough')
RejectedPassTrough = generate_rejected_test_case(method=on_rejected_not_a_function_pass_through,
                                                 value=sentinel,
                                                 module=__name__,
                                                 name='RejectedPassTrough')
Esempio n. 3
0
    def test_handlers():
        method_calls = [a[0] for a in handler_mock.method_calls]

        test_case.assertEquals(['handler01', 'handler02', 'handler03'], method_calls)

        done()

    def schedule_test(value):
        test_case.scheduler.schedule_task(test_handlers, 0.015)

    promise.then(schedule_test)


MultipleBoringTestCases = generate_fulfilled_test_case(method=multiple_boring_tests, value=sentinel,
                                                       module=__name__,
                                                       name='MultipleBoringTestCases')
MultipleOneThrowsTestCases = generate_fulfilled_test_case(method=multiple_one_throws, value=sentinel,
                                                          module=__name__,
                                                          name='MultipleOneThrowsTestCases')
MultipleBranchingTestCases = generate_fulfilled_test_case(method=multiple_branching_chains_each_with_own_value,
                                                          value=dummy,
                                                          module=__name__,
                                                          name='MultipleBranchingTestCases')
FulfilledHandlersInOrder = generate_fulfilled_test_case(method=on_fulfilled_handlers_called_in_original_order,
                                                        value=dummy,
                                                        module=__name__,
                                                        name='FulfilledHandlersInOrder')
OrderManipulatedInPromise = generate_fulfilled_test_case(method=order_manipulated_in_a_promise,
                                                         value=dummy,
                                                         module=__name__,