Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging functionality #44

Open
24 tasks
skasberger opened this issue Jun 26, 2020 · 1 comment
Open
24 tasks

Add logging functionality #44

skasberger opened this issue Jun 26, 2020 · 1 comment
Assignees
Labels
pkg:api api related activities pkg:models models related activities pkg:utils utils related activities prio:high status:confirmed Is a valid issue and will be moved forward soon. type:feature New feature

Comments

@skasberger
Copy link
Member

skasberger commented Jun 26, 2020

Add logging functionality to all modules.

Prepare

Snippets:

import requests
import json

def pretty_print_request(request):
    print( '\n{}\n{}\n\n{}\n\n{}\n'.format(
        '-----------Request----------->',
        request.method + ' ' + request.url,
        '\n'.join('{}: {}'.format(k, v) for k, v in request.headers.items()),
        request.body)
    )

def pretty_print_response(response):
    print('\n{}\n{}\n\n{}\n\n{}\n'.format(
        '<-----------Response-----------',
        'Status code:' + str(response.status_code),
        '\n'.join('{}: {}'.format(k, v) for k, v in response.headers.items()),
        response.text)
    )

def test_post_headers_body_json():
    url = 'https://httpbin.org/post'

    # Additional headers.
    headers = {'Content-Type': 'application/json' }

    # Body
    payload = {'key1': 1, 'key2': 'value2'}

    # convert dict to json by json.dumps() for body data.
    resp = requests.post(url, headers=headers, data=json.dumps(payload,indent=4))

    # Validate response headers and body contents, e.g. status code.
    assert resp.status_code == 200
    resp_body = resp.json()
    assert resp_body['url'] == url

    # print full request and response
    pretty_print_request(resp.request)
    pretty_print_response(resp)

Implementation

  • Define requirements
    • no console output by default. maybe through argument (part of Api.init()??).
    • [ ]
  • Write tests
  • Write code
  • Update Docs
    • add to user guide
  • Update Docstrings
  • Run pytest
  • Run tox
  • Run pylint
  • Run mypy

Review

  • Docs

Follow-Ups

@skasberger skasberger added info:help wanted Extra attention is needed type:review Review pkg:utils utils related activities pkg:models models related activities pkg:api api related activities prio:high labels Jun 26, 2020
@skasberger skasberger added this to the Later milestone Jun 26, 2020
@skasberger skasberger self-assigned this Jun 26, 2020
@skasberger skasberger added status:confirmed Is a valid issue and will be moved forward soon. and removed info:help wanted Extra attention is needed labels Jun 26, 2020
@skasberger skasberger added type:feature New feature and removed type:review Review labels Jan 26, 2021
@skasberger skasberger modified the milestones: Later, v0.4.0 Mar 14, 2021
@skasberger skasberger changed the title Add logging Add logging functionality Mar 14, 2021
@skasberger skasberger mentioned this issue Mar 14, 2021
35 tasks
@pdurbin
Copy link
Member

pdurbin commented Feb 14, 2024

As discussed during the 2024-02-14 meeting of the pyDataverse working group, we are closing old milestones in favor of a new project board at https://github.com/orgs/gdcc/projects/1 and removing issues (like this one) from those old milestones. Please feel free to join the working group! You can find us at https://py.gdcc.io and https://dataverse.zulipchat.com/#narrow/stream/377090-python

@pdurbin pdurbin removed this from the v0.4.0 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:api api related activities pkg:models models related activities pkg:utils utils related activities prio:high status:confirmed Is a valid issue and will be moved forward soon. type:feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants