-
-
Notifications
You must be signed in to change notification settings - Fork 350
/
test_build_app_context.py
88 lines (77 loc) · 2.93 KB
/
test_build_app_context.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def test_question_sequence(new_command):
"Questions are asked, a context is constructed."
# Prime answers for all the questions.
new_command.input.values = [
'My Application', # formal name
'', # app name - accept the default
'', # class name
'org.beeware', # bundle ID
'My Project', # project name
'Cool stuff', # description
'Grace Hopper', # author
'grace@navy.mil', # author email
'https://navy.mil/myapplication', # URL
'4', # license
'1', # GUI toolkit
]
assert new_command.build_app_context() == {
'formal_name': 'My Application',
'app_name': 'myapplication',
'class_name': 'MyApplication',
'module_name': 'myapplication',
'bundle': 'org.beeware',
'project_name': 'My Project',
'description': 'Cool stuff',
'author': 'Grace Hopper',
'author_email': 'grace@navy.mil',
'url': 'https://navy.mil/myapplication',
'license': 'GNU General Public License v2 (GPLv2)',
'gui_framework': 'Toga',
}
def test_question_sequence_with_nondefault_gui(new_command):
"Questions are asked, a context is constructed, but the GUI option is formatted to extract the GUI name."
# Prime answers for all the questions.
new_command.input.values = [
'My Application', # formal name
'', # app name - accept the default
'', # class name
'org.beeware', # bundle ID
'My Project', # project name
'Cool stuff', # description
'Grace Hopper', # author
'grace@navy.mil', # author email
'https://navy.mil/myapplication', # URL
'4', # license
'2', # GUI toolkit
]
assert new_command.build_app_context() == {
'formal_name': 'My Application',
'app_name': 'myapplication',
'class_name': 'MyApplication',
'module_name': 'myapplication',
'bundle': 'org.beeware',
'project_name': 'My Project',
'description': 'Cool stuff',
'author': 'Grace Hopper',
'author_email': 'grace@navy.mil',
'url': 'https://navy.mil/myapplication',
'license': 'GNU General Public License v2 (GPLv2)',
'gui_framework': 'PySide2',
}
def test_question_sequence_with_no_user_input(new_command):
"If no user input is provided, all user inputs are taken as default"
new_command.input.enabled = False
assert new_command.build_app_context() == {
'app_name': 'helloworld',
'author': 'Jane Developer',
'author_email': 'jane@example.com',
'bundle': 'com.example',
'class_name': 'HelloWorld',
'description': 'My first application',
'formal_name': 'Hello World',
'gui_framework': 'Toga',
'license': 'BSD license',
'module_name': 'helloworld',
'project_name': 'Hello World',
'url': 'https://example.com/helloworld'
}