|
8 | 8 | from products.nativescript.tns import Tns
|
9 | 9 |
|
10 | 10 |
|
| 11 | +# noinspection PyMethodMayBeStatic |
11 | 12 | class CreateTests(TnsTest):
|
12 |
| - app_data_JS = Apps.HELLO_WORLD_JS |
13 |
| - app_data_TS = Apps.HELLO_WORLD_TS |
14 |
| - app_data_NG = Apps.HELLO_WORLD_NG |
15 |
| - |
16 |
| - js_app = Settings.AppName.DEFAULT + 'JS' |
17 |
| - ts_app = Settings.AppName.DEFAULT + 'TS' |
18 |
| - ng_app = Settings.AppName.DEFAULT + 'NG' |
19 |
| - |
20 |
| - js_app_space = Settings.AppName.WITH_SPACE |
21 |
| - js_app_dash = Settings.AppName.WITH_DASH |
22 |
| - js_app_number = Settings.AppName.WITH_NUMBER |
23 | 13 |
|
24 | 14 | @classmethod
|
25 | 15 | def setUpClass(cls):
|
26 | 16 | TnsTest.setUpClass()
|
27 | 17 |
|
28 | 18 | def setUp(self):
|
29 | 19 | TnsTest.setUp(self)
|
30 |
| - Folder.clean(os.path.join(Settings.TEST_RUN_HOME, 'folder')) |
31 |
| - Folder.clean(os.path.join(Settings.TEST_RUN_HOME, 'js_app_space')) |
32 |
| - Folder.clean(os.path.join(Settings.TEST_RUN_HOME, 'js_app_dash')) |
33 |
| - Folder.clean(os.path.join(Settings.TEST_RUN_HOME, 'js_app_number')) |
| 20 | + CreateTests.__clean_folders() |
34 | 21 |
|
35 | 22 | @classmethod
|
36 | 23 | def tearDownClass(cls):
|
37 | 24 | TnsTest.tearDownClass()
|
| 25 | + CreateTests.__clean_folders() |
38 | 26 |
|
39 | 27 | def test_001_create_app_like_real_user(self):
|
40 |
| - Tns.create(app_name=self.js_app, app_data=None) |
| 28 | + """Create app with no any params""" |
| 29 | + Tns.create(app_name=Settings.AppName.DEFAULT, app_data=Apps.HELLO_WORLD_JS, update=False) |
41 | 30 |
|
42 | 31 | def test_002_create_app_template_js(self):
|
43 |
| - """Create app with --template js project without update modules""" |
44 |
| - Tns.create(app_name=self.js_app, template=Template.HELLO_WORLD_JS.local_package, |
45 |
| - app_data=self.app_data_JS, update=False, verify=False) |
| 32 | + """Create app with --template js project""" |
| 33 | + Tns.create(app_name=Settings.AppName.DEFAULT, template=Template.HELLO_WORLD_JS.local_package, |
| 34 | + app_data=Apps.HELLO_WORLD_JS, update=False) |
46 | 35 |
|
47 | 36 | def test_003_create_app_template_ts(self):
|
48 |
| - """Create app with --template ts project without update modules""" |
49 |
| - Tns.create(app_name=self.ts_app, template=Template.HELLO_WORLD_TS.local_package, |
50 |
| - app_data=self.app_data_TS, update=False, verify=False) |
| 37 | + """Create app with --template ts project""" |
| 38 | + Tns.create(app_name=Settings.AppName.DEFAULT, template=Template.HELLO_WORLD_TS.local_package, |
| 39 | + app_data=Apps.HELLO_WORLD_TS, update=False) |
51 | 40 |
|
52 | 41 | def test_004_create_app_template_ng(self):
|
53 |
| - """Create app with --template ng project without update modules""" |
54 |
| - Tns.create(app_name=self.ng_app, template=Template.HELLO_WORLD_NG.local_package, |
55 |
| - app_data=self.app_data_NG, update=False, verify=False) |
| 42 | + """Create app with --template ng project""" |
| 43 | + Tns.create(app_name=Settings.AppName.DEFAULT, template=Template.HELLO_WORLD_NG.local_package, |
| 44 | + app_data=Apps.HELLO_WORLD_NG, update=False) |
56 | 45 |
|
57 | 46 | def test_005_create_project_with_path(self):
|
58 | 47 | """Create project with --path option"""
|
59 |
| - Tns.create(app_name=self.js_app, template=Template.HELLO_WORLD_JS.local_package, |
60 |
| - app_data=self.app_data_JS, path=os.path.join(Settings.TEST_RUN_HOME, 'folder', 'subfolder'), |
61 |
| - update=False, verify=False) |
62 |
| - assert Folder.exists(os.path.join(Settings.TEST_RUN_HOME, 'folder', 'subfolder', 'TestAppJS')) |
| 48 | + Tns.create(app_name=Settings.AppName.DEFAULT, |
| 49 | + template=Template.HELLO_WORLD_JS.local_package, |
| 50 | + app_data=Apps.HELLO_WORLD_JS, |
| 51 | + path=os.path.join(Settings.TEST_RUN_HOME, 'folder', 'subfolder'), |
| 52 | + update=False) |
63 | 53 |
|
64 |
| - def test_006_create_project_with_space(self): |
| 54 | + def test_006_create_project_with_dash(self): |
65 | 55 | """ Create project with space is possible, but packageId will skip the space symbol"""
|
66 |
| - Tns.create(app_name=self.js_app_space, template=Template.HELLO_WORLD_JS.local_package, |
67 |
| - app_data=self.app_data_JS, update=False, verify=False) |
| 56 | + Tns.create(app_name=Settings.AppName.WITH_DASH, template=Template.HELLO_WORLD_JS.local_package, |
| 57 | + app_data=Apps.HELLO_WORLD_JS, update=False) |
68 | 58 |
|
69 | 59 | def test_007_create_project_with_space(self):
|
70 | 60 | """ Create project with dash is possible, but packageId will skip the dash symbol"""
|
71 |
| - Tns.create(app_name=self.js_app_dash, template=Template.HELLO_WORLD_JS.local_package, |
72 |
| - app_data=self.app_data_JS, update=False, verify=False) |
| 61 | + Tns.create(app_name=Settings.AppName.WITH_SPACE, template=Template.HELLO_WORLD_JS.local_package, |
| 62 | + app_data=Apps.HELLO_WORLD_JS, update=False) |
73 | 63 |
|
74 | 64 | def test_008_create_project_named_123(self):
|
75 | 65 | """Create app starting with digits should not be possible without --force option"""
|
76 |
| - Tns.create(app_name=self.js_app_number, template=Template.HELLO_WORLD_JS.local_package, |
77 |
| - app_data=self.app_data_JS, update=False, verify=False) |
78 |
| - # TODO: package_json contains |
| 66 | + result = Tns.create(app_name=Settings.AppName.WITH_NUMBER, template=Template.HELLO_WORLD_JS.local_package, |
| 67 | + app_data=Apps.HELLO_WORLD_JS, update=False, verify=False) |
| 68 | + assert 'The project name does not start with letter and will fail to build for Android.' in result.output |
| 69 | + assert 'If You want to create project with this name add --force to the create command.' in result.output |
| 70 | + |
| 71 | + Tns.create(app_name=Settings.AppName.WITH_NUMBER, template=Template.HELLO_WORLD_JS.local_package, |
| 72 | + app_data=Apps.HELLO_WORLD_JS, force=True, update=False) |
79 | 73 |
|
80 | 74 | def test_009_create_project_with_appid(self):
|
81 | 75 | """Create project with --appid option"""
|
82 |
| - Tns.create(app_name=self.js_app, template=Template.HELLO_WORLD_JS.local_package, app_data=self.app_data_JS, |
83 |
| - update=False, verify=False, app_id='org.nativescript.MyApp') |
| 76 | + Tns.create(app_name=Settings.AppName.DEFAULT, template=Template.HELLO_WORLD_JS.local_package, |
| 77 | + app_data=Apps.HELLO_WORLD_JS, update=False, app_id='org.nativescript.MyApp') |
| 78 | + |
| 79 | + @staticmethod |
| 80 | + def __clean_folders(): |
| 81 | + Folder.clean(os.path.join(Settings.TEST_RUN_HOME, 'folder')) |
| 82 | + Folder.clean(os.path.join(Settings.TEST_RUN_HOME, Settings.AppName.WITH_SPACE)) |
| 83 | + Folder.clean(os.path.join(Settings.TEST_RUN_HOME, Settings.AppName.WITH_DASH)) |
| 84 | + Folder.clean(os.path.join(Settings.TEST_RUN_HOME, Settings.AppName.WITH_NUMBER)) |
0 commit comments