-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_gm.py
70 lines (45 loc) · 1.46 KB
/
test_gm.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from os import environ
import openai
import pytest
from github import Event, Github
from gm import GH_EVENTS, event_dict, github_event, hey_gpt
openai.api_key = environ["OPENAI_KEY"]
@pytest.fixture(scope="session")
def events(pytestconfig):
token = pytestconfig.getoption("token")
g = Github(token)
u = g.get_user()
e = [e for e in u.get_events().get_page(0) if e.type in GH_EVENTS]
return e
def test_event_is_event_event_type(events):
assert isinstance(events[0], Event.Event)
def test_event_has_repo(events):
assert events[0].repo is not None
def test_event_has_actor(events):
assert events[0].actor is not None
def test_event_has_payload(events):
assert events[0].payload is not None
def test_event_has_created_at(events):
assert events[0].created_at is not None
def test_event_has_id(events):
assert events[0].id is not None
def test_gh_events_allowed():
assert len(GH_EVENTS) == 6
def test_event_dict(events):
for e in events:
e_dict_keys = event_dict(e).keys()
assert len(e_dict_keys) == 3
assert list(e_dict_keys) == ["repo", "type", "created_at"]
def test_github_event_serial(events):
for e in events:
github_event(e)
@pytest.mark.slow
def test_hey_gpt(events):
e_log = []
for e in events:
e_log.append(github_event(e))
ai_out = hey_gpt(e_log)
assert isinstance(ai_out, str)
assert len(ai_out) > 0