Skip to content

Commit efaeea4

Browse files
author
Miroslava Ivanova
committed
new create tests
1 parent b5989e0 commit efaeea4

File tree

4 files changed

+78
-36
lines changed

4 files changed

+78
-36
lines changed

core/settings/Settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ class AppName(object):
140140
DEFAULT_NG = 'TestApp'
141141
WITH_DASH = 'tns-app'
142142
WITH_SPACE = 'Test App'
143+
WITH_NUMBER = '123'

products/nativescript/tns_assert.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from core.utils.file_utils import File
77
from core.utils.json_utils import JsonUtils
88
from core.utils.perf_utils import PerfUtils
9+
from products.nativescript.tns_helpers import TnsHelpers
910

1011

1112
class TnsAssert(object):
@@ -32,34 +33,16 @@ def created(app_name, output=None, app_data=None):
3233
if app_data is not None:
3334
# Assert app type
3435
assert Folder.exists(os.path.join(app_path, TnsAssert.TNS_MODULES))
35-
assert Folder.exists(os.path.join(app_path, TnsAssert.TNS_MODULES))
36-
assert Folder.exists(os.path.join(app_path, TnsAssert.TNS_MODULES))
3736
assert Folder.exists(os.path.join(app_path, TnsAssert.NODE_MODULES, 'nativescript-theme-core'))
3837
assert Folder.exists(os.path.join(app_path, TnsAssert.NODE_MODULES, 'nativescript-dev-webpack'))
3938

4039
if app_data.type is AppType.JS:
4140
pass
4241
elif app_data.type is AppType.TS:
43-
assert File.exists(os.path.join(app_path, 'tsconfig.json'))
44-
assert File.exists(os.path.join(app_path, 'webpack.config.js'))
45-
assert File.exists(os.path.join(app_path, 'tsconfig.tns.json'))
46-
assert not File.exists(os.path.join(app_path, 'references.d.ts'))
47-
assert File.exists(os.path.join(app_path, TnsAssert.TNS_MODULES, 'tns-core-modules.d.ts'))
48-
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-prepare',
49-
'nativescript-dev-typescript.js'))
50-
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-watch',
51-
'nativescript-dev-typescript.js'))
42+
TnsAssert.__verify_created_ts()
5243
pass
5344
elif app_data.type is AppType.NG:
54-
assert File.exists(os.path.join(app_path, 'tsconfig.json'))
55-
assert File.exists(os.path.join(app_path, 'webpack.config.js'))
56-
assert File.exists(os.path.join(app_path, 'tsconfig.tns.json'))
57-
assert not File.exists(os.path.join(app_path, 'references.d.ts'))
58-
assert File.exists(os.path.join(app_path, TnsAssert.TNS_MODULES, 'tns-core-modules.d.ts'))
59-
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-prepare',
60-
'nativescript-dev-typescript.js'))
61-
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-watch',
62-
'nativescript-dev-typescript.js'))
45+
TnsAssert.__verify_created_ng()
6346
pass
6447
elif app_data.type is AppType.VUE:
6548
pass
@@ -110,3 +93,29 @@ def build(app_name, platform=None, release=False, provision=Settings.IOS.DEV_PRO
11093
# Assert size
11194
if app_data.size is not None:
11295
pass
96+
97+
@staticmethod
98+
def __verify_created_ts():
99+
app_path = TnsHelpers.get_app_path(app_name='TestAppTS')
100+
assert File.exists(os.path.join(app_path, 'tsconfig.json'))
101+
assert File.exists(os.path.join(app_path, 'webpack.config.js'))
102+
assert File.exists(os.path.join(app_path, 'tsconfig.tns.json'))
103+
assert not File.exists(os.path.join(app_path, 'references.d.ts'))
104+
assert File.exists(os.path.join(app_path, TnsAssert.TNS_MODULES, 'tns-core-modules.d.ts'))
105+
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-prepare',
106+
'nativescript-dev-typescript.js'))
107+
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-watch',
108+
'nativescript-dev-typescript.js'))
109+
110+
@staticmethod
111+
def __verify_created_ng():
112+
app_path = TnsHelpers.get_app_path(app_name='TestAppNG')
113+
assert File.exists(os.path.join(app_path, 'tsconfig.json'))
114+
assert File.exists(os.path.join(app_path, 'webpack.config.js'))
115+
assert File.exists(os.path.join(app_path, 'tsconfig.tns.json'))
116+
assert not File.exists(os.path.join(app_path, 'references.d.ts'))
117+
assert File.exists(os.path.join(app_path, TnsAssert.TNS_MODULES, 'tns-core-modules.d.ts'))
118+
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-prepare',
119+
'nativescript-dev-typescript.js'))
120+
assert File.exists(os.path.join(app_path, TnsAssert.HOOKS, 'before-watch',
121+
'nativescript-dev-typescript.js'))

products/nativescript/tns_helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
import os
2+
3+
from core.settings import Settings
4+
15

26
class TnsHelpers(object):
37

8+
@staticmethod
9+
def get_app_path(app_name):
10+
app_path = os.path.join(Settings.TEST_RUN_HOME, app_name)
11+
return app_path
12+
413
@staticmethod
514
def get_apk(app_name):
615
return ''

tests/cli/create/create_tests.py

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,83 @@
11
import os
22

33
from core.base_test.tns_test import TnsTest
4-
from core.enums.app_type import AppType
4+
from core.utils.file_utils import Folder
55
from data.apps import Apps
66
from core.settings import Settings
77
from data.templates import Template
88
from products.nativescript.tns import Tns
99

1010

1111
class CreateTests(TnsTest):
12-
app_name_dash = "tns-app"
13-
app_name_space = "TNS App"
14-
app_name_123 = "123"
15-
app_name_app = "app"
1612
app_data_JS = Apps.HELLO_WORLD_JS
1713
app_data_TS = Apps.HELLO_WORLD_TS
1814
app_data_NG = Apps.HELLO_WORLD_NG
1915

2016
js_app = Settings.AppName.DEFAULT + 'JS'
21-
js_source_project_dir = os.path.join(Settings.TEST_RUN_HOME, js_app)
22-
js_target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', js_app)
23-
2417
ts_app = Settings.AppName.DEFAULT + 'TS'
25-
2618
ng_app = Settings.AppName.DEFAULT + 'NG'
27-
ng_source_project_dir = os.path.join(Settings.TEST_RUN_HOME, ng_app)
28-
ng_target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', ng_app)
2919

3020
js_app_space = Settings.AppName.WITH_SPACE
21+
js_app_dash = Settings.AppName.WITH_DASH
22+
js_app_number = Settings.AppName.WITH_NUMBER
3123

3224
@classmethod
3325
def setUpClass(cls):
3426
TnsTest.setUpClass()
3527

3628
def setUp(self):
3729
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'))
3834

3935
@classmethod
4036
def tearDownClass(cls):
4137
TnsTest.tearDownClass()
4238

4339
def test_001_create_app_like_real_user(self):
4440
Tns.create(app_name=self.js_app, app_data=None)
45-
s
41+
4642
def test_002_create_app_template_js(self):
47-
Tns.create(app_name=self.js_app, template=Template.HELLO_WORLD_JS.local_package, app_data=self.app_data_JS)
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)
4846

4947
def test_003_create_app_template_ts(self):
50-
Tns.create(app_name=self.ts_app, template=Template.HELLO_WORLD_TS.local_package, app_data=self.app_data_TS)
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)
5151

5252
def test_004_create_app_template_ng(self):
53-
Tns.create(app_name=self.ng_app, template=Template.HELLO_WORLD_NG.local_package, app_data=self.app_data_NG)
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)
5456

5557
def test_005_create_project_with_path(self):
5658
"""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'))
5763

5864
def test_006_create_project_with_space(self):
5965
""" Create project with space is possible, but packageId will skip the space symbol"""
60-
Tns.create(app_name=self.js_app_space, template=Template.HELLO_WORLD_JS.local_package, app_data=self.app_data_JS)
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

Comments
 (0)