コード例 #1
0
def test_literal_input():
    do_test(
        GraphQLVoid.parse_literal,
        [
            (StringValueNode(value='hello'), None),
        ],
    )
コード例 #2
0
def test_input():
    do_test(
        GraphQLDateTime.parse_value,
        [
            (
                '2077-07-07T07:07:07.123+07:07',
                datetime(2077, 7, 7, 0, 0, 7, 123 * 1000, timezone.utc),
            ),
            (
                '1999-09-09T09:09:09.456+09:09',
                datetime(1999, 9, 9, 0, 0, 9, 456 * 1000, timezone.utc),
            ),
            (
                '2020-02-20T20:20:20.789-02:20',
                datetime(2020, 2, 20, 22, 40, 20, 789 * 1000, timezone.utc),
            ),
            ('2020-02-02T20:20:20+00:00',
             datetime(2020, 2, 2, 20, 20, 20, tzinfo=timezone.utc)),
            ('2008-08-08T08:08:08Z',
             datetime(2008, 8, 8, 8, 8, 8, tzinfo=timezone.utc)),
            ('2020', datetime(2020, 1, 1, tzinfo=timezone.utc)),
            (123, TypeError),
            (True, TypeError),
            (False, TypeError),
            (123.321, TypeError),
            ('2020-02-02T20:20:20', ValueError),
        ],
    )
コード例 #3
0
def test_user_entrypoints(cli_func, method, cli_args, call_kwargs, runner,
                          mocked_users_api):
    state = State(format=OutputFormatter(output=print),
                  api=mocked_users_api,
                  user_token='abcdef')

    call_kwargs['user_token'] = 'abcdef'
    do_test(cli_func, method, cli_args, call_kwargs, runner, state)
コード例 #4
0
ファイル: test_json.py プロジェクト: ATyped/graphql-scalars
def test_json_serializer():
    Settings.json_serializers[int] = lambda v: v + 1
    Settings.json_serializers[dict] = lambda _: {}

    do_test(GraphQLJSON.serialize, [(1, 2), (2.0, 2.0), ({1: 1}, {})])

    Settings.json_serializers[int] = lambda _: type  # type: ignore[assignment, return-value]

    do_test(GraphQLJSON.serialize, [(1, TypeError)])
コード例 #5
0
def test_output():
    do_test(
        GraphQLVoid.serialize,
        [
            (1, None),
            (2.0, None),
            ('3', None),
            (True, None),
            ({}, None),
        ],
    )
コード例 #6
0
def test_variable_input():
    do_test(
        GraphQLVoid.parse_value,
        [
            (4, None),
            (5.0, None),
            ('6', None),
            (False, None),
            ({}, None),
        ],
    )
コード例 #7
0
def test_user_setlist_set_entrypoints(cli_func, method, cli_args, call_kwargs,
                                      runner, mocked_users_api):
    state = State(format=OutputFormatter(output=print),
                  api=mocked_users_api,
                  user_token='abcdef',
                  list_id=987654321,
                  set_num='1357-1')

    call_kwargs['list_id'] = 987654321
    call_kwargs['user_token'] = 'abcdef'
    call_kwargs['set_num'] = '1357-1'

    do_test(cli_func, method, cli_args, call_kwargs, runner, state)
コード例 #8
0
ファイル: test_json.py プロジェクト: ATyped/graphql-scalars
def test_variable_input():
    do_test(
        GraphQLJSON.parse_value,
        [
            (2, 2),
            (False, False),
            (3.8, 3.8),
            ([6, 7, 8], [6, 7, 8]),
            ([4, '5', True], [4, '5', True]),
            ((7, '9'), (7, '9')),
            ({'Hello': 'World'}, {'Hello': 'World'}),
            (int, TypeError),
        ],
    )
コード例 #9
0
ファイル: test_json.py プロジェクト: ATyped/graphql-scalars
def test_output():
    do_test(
        GraphQLJSON.serialize,
        [
            (1, 1),
            (True, True),
            (1.2, 1.2),
            ([1, 2, 3], [1, 2, 3]),
            ([4, '5', False], [4, '5', False]),
            ((1, 2), (1, 2)),
            ({}, {}),
            (type, TypeError),
        ],
    )
コード例 #10
0
def test_user_partlist_part_entrypoints(cli_func, method, cli_args,
                                        call_kwargs, runner, mocked_users_api):
    state = State(format=OutputFormatter(output=print),
                  api=mocked_users_api,
                  user_token='abcdef',
                  list_id=987654321,
                  color_id=45,
                  part_num='3004')

    call_kwargs['color_id'] = 45
    call_kwargs['part_num'] = '3004'
    call_kwargs['list_id'] = 987654321
    call_kwargs['user_token'] = 'abcdef'

    do_test(cli_func, method, cli_args, call_kwargs, runner, state)
コード例 #11
0
def test_input():
    do_test(
        GraphQLTimestamp.parse_value,
        [
            (3392841607123,
             datetime(2077, 7, 7, 0, 0, 7, 123 * 1000, timezone.utc)),
            (936835209456,
             datetime(1999, 9, 9, 0, 0, 9, 456 * 1000, timezone.utc)),
            ('2020-02-20T20:20:20.789-02:20', TypeError),
            ('2020-02-02T20:20:20+00:00', TypeError),
            ('2008-08-08T08:08:08Z', TypeError),
            (True, TypeError),
            (False, TypeError),
        ],
    )
コード例 #12
0
def test_output():
    do_test(
        GraphQLTimestamp.serialize,
        [
            (datetime(2077, 7, 7, 0, 0, 7, 123 * 1000,
                      timezone.utc), 3392841607123),
            (datetime(1999, 9, 9, 8, 0, 9, 456 * 1000,
                      timezone(timedelta(hours=8))), 936835209456),
            ('2008-08-08T08:08:08Z', 1218182888000),
            (date(2020, 1, 1), 1577836800000),
            (123, TypeError),
            (True, TypeError),
            (123.456, TypeError),
        ],
    )
コード例 #13
0
ファイル: test_json.py プロジェクト: ATyped/graphql-scalars
def test_literal_value_input():
    do_test(
        GraphQLJSON.parse_literal,
        [
            (StringValueNode(value='hello'), 'hello'),
            (IntValueNode(value=1), 1),
            (FloatValueNode(value=2.0), 2.0),
            (BooleanValueNode(value=True), True),
            (
                ListValueNode(
                    values=[StringValueNode(value='hello'), StringValueNode(value='world')]
                ),
                ['hello', 'world'],
            ),
            (NullValueNode(), None),
        ],
    )
コード例 #14
0
def test_output():
    do_test(
        GraphQLDateTime.serialize,
        [
            ('2077-07-07T07:07:07.123+07:07',
             '2077-07-07T00:00:07.123000+00:00'),
            ('2008-08-08T08:08:08Z', '2008-08-08T08:08:08+00:00'),
            ('2021', '2021-01-01T00:00:00+00:00'),
            ('2077-07-07', '2077-07-07T00:00:00+00:00'),
            ('1997-07', '1997-07-01T00:00:00+00:00'),
            (datetime(1945, 5, 4), '1945-05-04T00:00:00+00:00'),
            (date(2033, 6, 1), '2033-06-01T00:00:00+00:00'),
            (Arrow(1989, 12, 31, 12, 31, 24), '1989-12-31T12:31:24+00:00'),
            (123, TypeError),
            (True, TypeError),
            (123.456, TypeError),
        ],
    )
コード例 #15
0
def test_users_operations(cli_func, method, cli_args, call_kwargs, runner,
                          mocked_users_api):
    state = State(format=OutputFormatter(output=print), api=mocked_users_api)

    do_test(cli_func, method, cli_args, call_kwargs, runner, state)
コード例 #16
0
def test_lego_part_color_entrypoints(cli_func, method, cli_args, call_kwargs,
                                     runner, mocked_state):
    call_kwargs['part_num'] = '3004'
    call_kwargs['color_id'] = 45

    do_test(cli_func, method, cli_args, call_kwargs, runner, mocked_state)
コード例 #17
0
def test_lego_set_entrypoints(cli_func, method, cli_args, call_kwargs, runner,
                              mocked_state):
    call_kwargs['set_num'] = '75192-1'

    do_test(cli_func, method, cli_args, call_kwargs, runner, mocked_state)
コード例 #18
0
def test_lego_entrypoints(cli_func, method, cli_args, call_kwargs, runner,
                          mocked_state):
    do_test(cli_func, method, cli_args, call_kwargs, runner, mocked_state)
コード例 #19
0
def test_lego_moc_entrypoints(cli_func, method, cli_args, call_kwargs, runner,
                              mocked_state):
    mocked_state.set_num = 'MOC-5634'
    call_kwargs['set_num'] = 'MOC-5634'

    do_test(cli_func, method, cli_args, call_kwargs, runner, mocked_state)