[modules/gitlab] add module
This commit is contained in:
parent
f77f5552ae
commit
7161ef211c
6 changed files with 127 additions and 0 deletions
42
tests/modules/contrib/test_gitlab.py
Normal file
42
tests/modules/contrib/test_gitlab.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
from unittest import TestCase, mock
|
||||
|
||||
import core.config
|
||||
import core.widget
|
||||
import modules.contrib.gitlab
|
||||
|
||||
from requests import Session
|
||||
from requests.models import Response
|
||||
|
||||
pytest.importorskip("requests")
|
||||
|
||||
|
||||
def build_gitlab_module(actions=""):
|
||||
config = core.config.Config(["-p", "gitlab.actions={}".format(actions)])
|
||||
return modules.contrib.gitlab.Module(config=config, theme=None)
|
||||
|
||||
def mock_todo_api_response():
|
||||
res = mock.Mock()
|
||||
res.json = lambda: [
|
||||
{"action_name": "assigned"},
|
||||
{"action_name": "assigned"},
|
||||
{"action_name": "approval_required"},
|
||||
]
|
||||
res.status_code = 200
|
||||
return res
|
||||
|
||||
class TestGitlabUnit(TestCase):
|
||||
def test_load_module(self):
|
||||
__import__("modules.contrib.gitlab")
|
||||
|
||||
@mock.patch.object(Session, "get", return_value=mock_todo_api_response())
|
||||
def test_unfiltered(self, _):
|
||||
module = build_gitlab_module()
|
||||
module.update()
|
||||
assert module.widgets()[0].full_text() == "3"
|
||||
|
||||
@mock.patch.object(Session, "get", return_value=mock_todo_api_response())
|
||||
def test_filtered(self, _):
|
||||
module = build_gitlab_module(actions="approval_required")
|
||||
module.update()
|
||||
assert module.widgets()[0].full_text() == "1"
|
Loading…
Add table
Add a link
Reference in a new issue