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

chore: add tests and upgrade version #23

Merged
merged 10 commits into from
Feb 9, 2024
Merged

Conversation

nakamasato
Copy link
Owner

@nakamasato nakamasato commented Feb 9, 2024

what

  • upgrade python to 3.12
  • add tests

why

to improve maintainability

ref

Detailed Check

  • def test_request_example(client):
    signing_secret = "test_signing_secret"
    os.environ["SIGNING_SECRET"] = signing_secret
    timestamp = str(int(time.time()))
    data = {
    "type": "url_verification",
    "challenge": "challenge",
    }
    signature = VERIFIER.generate_signature(timestamp=timestamp, body=json.dumps(data))
    print(f"{signature=}, {json.dumps(data).encode()=}")
    assert VERIFIER.is_valid(
    body=json.dumps(data), timestamp=timestamp, signature=signature
    )
    headers = {
    "X-Slack-Request-Timestamp": timestamp,
    "X-Slack-Signature": signature,
    "Content-Type": "application/json",
    }
    response = client.post(
    "/slack/events",
    data=json.dumps(data),
    # json=data, # The Content-Type header will be set to application/json automatically.
    headers=headers,
    )
    print(response)
    assert hmac.compare_digest(
    signature,
    VERIFIER.generate_signature(timestamp=timestamp, body=json.dumps(data)),
    )
    assert VERIFIER.is_valid_request(body=json.dumps(data), headers=headers)
    assert response.status_code == 200

Copy link

github-actions bot commented Feb 9, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
slack_gpt
   main.py51688%42–43, 88–94, 111
TOTAL51688% 

Tests Skipped Failures Errors Time
4 0 💤 0 ❌ 0 🔥 3.208s ⏱️

@nakamasato nakamasato marked this pull request as ready for review February 9, 2024 12:29
@nakamasato nakamasato merged commit 528b6f6 into main Feb 9, 2024
2 checks passed
@nakamasato nakamasato deleted the update-version-and-tests branch February 9, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant