-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_main.py
35 lines (27 loc) · 1.22 KB
/
test_main.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
import unittest
from unittest.mock import patch
from kivymd.app import MDApp
from main import JiraTrackerApp
class TestJiraTrackerApp(unittest.TestCase):
@patch('main.get_key')
def test_environment_variables_not_set(self, mock_get_key):
# Simulate environment variables not being set
mock_get_key.return_value = None
# Initialize the app and check the returned widget
app = JiraTrackerApp()
widget = app.build()
# Assert that JiraConnectionSettingsPopup is initialized when env vars are not set
from jira_connection_settings_popup import JiraConnectionSettingsPopup
self.assertIsInstance(widget, JiraConnectionSettingsPopup)
@patch('main.get_key')
def test_environment_variables_set(self, mock_get_key):
# Simulate environment variables being set
mock_get_key.return_value = 'some_value'
# Initialize the app and check the returned widget
app = JiraTrackerApp()
widget = app.build()
# Assert that JiraIssueTracker is initialized when env vars are set
from jira_issue_tracker import JiraIssueTracker
self.assertIsInstance(widget, JiraIssueTracker)
if __name__ == '__main__':
unittest.main()