Skip to content

Commit

Permalink
Updates for dependency changes
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 9, 2023
1 parent 57dc693 commit e79548a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
11 changes: 2 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
"python.pythonPath": "/usr/bin/python3",
"python.formatting.provider": "autopep8",
"editor.formatOnSave": true,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--rcfile",
"/home/netkan/workspace/.pylintrc"
],
"python.linting.mypyEnabled": true,
"python.linting.pylintUseMinimalCheckers": false,
"files.exclude": {
"**/__pycache__": true
},
Expand All @@ -18,5 +10,6 @@
"python.testing.unittestEnabled": false,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true
"files.trimFinalNewlines": true,
"mypy.configFile": "netkan/mypy.ini"
}
7 changes: 4 additions & 3 deletions netkan/netkan/github_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ def repo(self) -> Repository:
def default_branch(self) -> str:
return self.repo.default_branch

def create_pull_request(self, title: str, branch: str, body: str, labels: Optional[List[str]] = None) -> None:
def create_pull_request(self, title: str, branch: str, body: str,
labels: Optional[List[str]] = None) -> None:
try:
pull = self.repo.create_pull(
title, body, self.default_branch, branch)
pull = self.repo.create_pull(self.default_branch, branch,
title=title, body=body)
logging.info('Pull request for %s opened at %s',
branch, pull.html_url)

Expand Down
2 changes: 1 addition & 1 deletion netkan/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'jinja2',
'internetarchive!=3.0.1',
'gunicorn>=19.9,!=20.0.0',
'discord.py>=1.6.0',
'discord.py>=1.6.0,<=1.7.3',
'PyGithub',
'ruamel.yaml',
],
Expand Down
23 changes: 14 additions & 9 deletions netkan/tests/webhooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
from typing import Mapping, Any, cast

from unittest import mock, TestCase
from unittest.mock import MagicMock
Expand Down Expand Up @@ -121,7 +122,7 @@ def test_inflate_ksp_wrong_branch(self, sig: MagicMock):
response = self.client.post(
'/gh/inflate/ksp', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'Wrong branch'})
self.assertDictEqual(cast(Mapping[Any, object], response.json), {'message': 'Wrong branch'})

@mock.patch('netkan.webhooks.github_utils.sig_match')
def test_inflate_ksp2_wrong_branch(self, sig: MagicMock):
Expand All @@ -131,7 +132,7 @@ def test_inflate_ksp2_wrong_branch(self, sig: MagicMock):
response = self.client.post(
'/gh/inflate/ksp2', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'Wrong branch'})
self.assertDictEqual(cast(Mapping[Any, object], response.json), {'message': 'Wrong branch'})

@mock.patch('netkan.webhooks.github_utils.sig_match')
def test_inflate_ksp_no_commits(self, sig: MagicMock):
Expand All @@ -141,7 +142,8 @@ def test_inflate_ksp_no_commits(self, sig: MagicMock):
response = self.client.post(
'/gh/inflate/ksp', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'No commits received'})
self.assertDictEqual(cast(Mapping[Any, object], response.json),
{'message': 'No commits received'})

@mock.patch('netkan.webhooks.github_utils.sig_match')
def test_inflate_ksp2_no_commits(self, sig: MagicMock):
Expand All @@ -151,7 +153,8 @@ def test_inflate_ksp2_no_commits(self, sig: MagicMock):
response = self.client.post(
'/gh/inflate/ksp2', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'No commits received'})
self.assertDictEqual(cast(Mapping[Any, object], response.json),
{'message': 'No commits received'})

@mock.patch('netkan.status.ModStatus.get')
@mock.patch('netkan.webhooks.github_utils.sig_match')
Expand Down Expand Up @@ -251,7 +254,7 @@ def test_inflate_ksp_wrong_branch(self, sig: MagicMock):
response = self.client.post(
'/gh/mirror/ksp', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'Wrong branch'})
self.assertDictEqual(cast(Mapping[Any, object], response.json), {'message': 'Wrong branch'})

@mock.patch('netkan.webhooks.github_utils.sig_match')
def test_inflate_ksp2_wrong_branch(self, sig: MagicMock):
Expand All @@ -261,7 +264,7 @@ def test_inflate_ksp2_wrong_branch(self, sig: MagicMock):
response = self.client.post(
'/gh/mirror/ksp2', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'Wrong branch'})
self.assertDictEqual(cast(Mapping[Any, object], response.json), {'message': 'Wrong branch'})

@mock.patch('netkan.webhooks.github_utils.sig_match')
def test_inflate_ksp_no_commits(self, sig: MagicMock):
Expand All @@ -271,7 +274,8 @@ def test_inflate_ksp_no_commits(self, sig: MagicMock):
response = self.client.post(
'/gh/mirror/ksp', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'No commits received'})
self.assertDictEqual(cast(Mapping[Any, object], response.json),
{'message': 'No commits received'})

@mock.patch('netkan.webhooks.github_utils.sig_match')
def test_inflate_ksp2_no_commits(self, sig: MagicMock):
Expand All @@ -281,7 +285,8 @@ def test_inflate_ksp2_no_commits(self, sig: MagicMock):
response = self.client.post(
'/gh/mirror/ksp2', json=data, follow_redirects=True)
self.assertEqual(response.status_code, 200)
self.assertDictEqual(response.json, {'message': 'No commits received'})
self.assertDictEqual(cast(Mapping[Any, object], response.json),
{'message': 'No commits received'})


class TestWebhookInflate(WebhooksHarness):
Expand Down Expand Up @@ -433,7 +438,7 @@ def setUp(self) -> None:
@staticmethod
def mock_netkan_hook() -> dict:
return {
'name: Mod Name Entered by the User on spacedock'
'name': 'Mod Name Entered by the User on spacedock',
'id': '12345',
'license': 'GPL-3.0',
'username': 'modauthor1',
Expand Down

0 comments on commit e79548a

Please sign in to comment.