-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
49 lines (36 loc) · 1.17 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import unittest
from unittest.mock import patch
import flask_testing
from bot.app import app
from bot.gitlab.webhooks import Issue
class UsesApp(flask_testing.TestCase):
def create_app(self):
return app
class TestGitlabWebhooksIssue(unittest.TestCase):
def test_invalid_from_issue(self):
with open("tests/new_invalid_issue.json") as f:
data = json.loads(f.read())
issue = Issue.from_issue_hook(data)
assert issue.validated_labels == ["device:mako", "invalid"]
assert len(issue.errors) > 0
def test_valid(self):
data = {
"user": {"username": "banana"},
"object_attributes": {
"id": 1,
"description": "/device mako\\n/version lineage-18.1\\n/date 2021-04-01\\n/kernel 3\\n/mods None\\n/baseband 4",
},
}
issue = Issue.from_issue_hook(data)
assert issue.validated_labels == [
"device:mako",
"version:lineage-18.1",
"date",
"kernel",
"mods",
"baseband",
]
assert issue.errors == []
if __name__ == "__main__":
unittest.main()