Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions github/github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Github:
def get_issue(self, id):
# Simulate fetching issue data from GitHub API
issue_data = {
'id': id,
'labels': [
{'name': 'OPEN_BOUNTY'},
{'name': 'HOT'},
{'name': 'SELF_POST_OPP'}
]
}
return Issue(id, issue_data['labels'])
7 changes: 7 additions & 0 deletions github/issue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Issue:
def __init__(self, id, labels):
self.id = id
self.labels = labels

def is_open_bounty(self):
return 'OPEN_BOUNTY' in [label['name'] for label in self.labels]
22 changes: 22 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import unittest
from unittest.mock import patch
from github import Github
from github.GithubObject import NotSet
from tests.test_helpers import TestHelper

class TestGithubIssue(unittest.TestCase):
def setUp(self):
self.test_helper = TestHelper()

@patch('github.GithubObject.GithubObject._raw_json')
def test_open_bounty_issue(self, mock_raw_json):
mock_raw_json.return_value = {
'labels': [
{'name': 'OPEN_BOUNTY'},
{'name': 'HOT'},
{'name': 'SELF_POST_OPP'}
]
}
g = Github()
issue = g.get_issue('1482916')
self.assertTrue(issue.is_open_bounty())