|
| 1 | +import os |
| 2 | + |
| 3 | +from core.base_test.tns_test import TnsTest |
| 4 | +from core.utils.file_utils import Folder |
| 5 | +from data.apps import Apps |
| 6 | +from core.settings import Settings |
| 7 | +from data.templates import Template |
| 8 | +from products.nativescript.tns import Tns |
| 9 | + |
| 10 | + |
| 11 | +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 | + |
| 24 | + @classmethod |
| 25 | + def setUpClass(cls): |
| 26 | + TnsTest.setUpClass() |
| 27 | + |
| 28 | + def setUp(self): |
| 29 | + 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')) |
| 34 | + |
| 35 | + @classmethod |
| 36 | + def tearDownClass(cls): |
| 37 | + TnsTest.tearDownClass() |
| 38 | + |
| 39 | + def test_001_create_app_like_real_user(self): |
| 40 | + Tns.create(app_name=self.js_app, app_data=None) |
| 41 | + |
| 42 | + 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) |
| 46 | + |
| 47 | + 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) |
| 51 | + |
| 52 | + 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) |
| 56 | + |
| 57 | + def test_005_create_project_with_path(self): |
| 58 | + """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')) |
| 63 | + |
| 64 | + def test_006_create_project_with_space(self): |
| 65 | + """ 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) |
| 68 | + |
| 69 | + def test_007_create_project_with_space(self): |
| 70 | + """ 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) |
| 73 | + |
| 74 | + def test_008_create_project_named_123(self): |
| 75 | + """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 |
| 79 | + |
| 80 | + def test_009_create_project_with_appid(self): |
| 81 | + """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') |
0 commit comments