mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 14:32:28 +03:00
🎡 add unit tests for github.py
add unittests for our github api calls
This commit is contained in:
parent
1b19293ab0
commit
44b0af933d
3 changed files with 175 additions and 3 deletions
|
@ -19,9 +19,9 @@ import os
|
|||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
|
||||
class TmpCwd:
|
||||
|
@ -84,5 +84,13 @@ def parse_args_for_test(parser, args):
|
|||
for arg in args:
|
||||
if arg[0] == '-':
|
||||
flags.append(flags)
|
||||
with mock.patch('sys.argv', flags):
|
||||
with unittest.mock.patch('sys.argv', flags):
|
||||
parse_args(parser)
|
||||
|
||||
|
||||
def mock_urlopen(status=200, body=None):
|
||||
resp = unittest.mock.MagicMock()
|
||||
resp.getcode.return_value = status
|
||||
resp.read.return_value = body
|
||||
resp.__enter__.return_value = resp
|
||||
return unittest.mock.Mock(return_value=resp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue