Skip to content

Commit c3d95bb

Browse files
committed
1 parent 6f859d2 commit c3d95bb

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

core/tns/tns.py

+17
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,23 @@ def platform_remove(platform=Platform.NONE, attributes={}, assert_success=True,
229229
assert not File.exists(app_name + TnsAsserts.IOS)
230230
return output
231231

232+
@staticmethod
233+
def platform_clean(platform=Platform.NONE, attributes={}, assert_success=True, log_trace=False, tns_path=None):
234+
platform_string = Tns.__get_platform_string(platform)
235+
output = Tns.run_tns_command("platform clean " + platform_string, attributes=attributes, log_trace=log_trace,
236+
tns_path=tns_path)
237+
238+
app_name = Tns.__get_app_name_from_attributes(attributes)
239+
if assert_success:
240+
assert "Platform {0} successfully removed".format(platform_string) in output
241+
assert "error" not in output
242+
if platform is Platform.ANDROID:
243+
assert File.exists(app_name + TnsAsserts.PLATFORM_ANDROID)
244+
if platform is Platform.IOS:
245+
assert File.exists(app_name + TnsAsserts.IOS)
246+
assert "Project successfully created" in output
247+
return output
248+
232249
@staticmethod
233250
def platform_update(platform=Platform.NONE, version=None, attributes={}, assert_success=True, log_trace=False,
234251
tns_path=None):

tests/build/android/platform_android_tests.py

+12
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ def test_210_platform_update_android_when_platform_not_added(self):
7171
assert_success=False)
7272
TnsAsserts.platform_added(self.app_name, platform=Platform.ANDROID, output=output)
7373

74+
def test_220_platform_clean_android(self):
75+
"""Prepare after `platform clean` should add the same version that was before clean"""
76+
77+
# Create project with [email protected]
78+
Tns.create_app(self.app_name, update_modules=False)
79+
Tns.platform_add_android(version="2.4.0", attributes={"--path": self.app_name})
80+
TnsAsserts.package_json_contains(self.app_name, ["\"version\": \"2.4.0\""])
81+
82+
# Clean platform and verify platform is 2.4.0
83+
Tns.platform_clean(platform=Platform.ANDROID, attributes={"--path": self.app_name})
84+
TnsAsserts.package_json_contains(self.app_name, ["\"version\": \"2.4.0\""])
85+
7486
def test_300_set_sdk(self):
7587
"""Platform add android should be able to specify target sdk with `--sdk` option"""
7688
Tns.create_app(self.app_name, update_modules=False)

tests/build/common/create_tests.py

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from nose_parameterized import parameterized
77

88
from core.base_class.BaseClass import BaseClass
9+
from core.osutils.file import File
910
from core.osutils.folder import Folder
1011
from core.settings.settings import CLI_PATH, BRANCH
1112
from core.settings.strings import *
@@ -155,6 +156,14 @@ def test_201_create_project_with_local_directory_template(self):
155156
strings = ["\"tns-core-modules\":", "\"lodash\": \"3.10.1\"", "\"minimist\": \"1.2.0\""]
156157
TnsAsserts.package_json_contains(self.app_name, string_list=strings)
157158

159+
def test_300_create_project_with_no_app_resoruces(self):
160+
"""--template should not create project if value is no npm installable"""
161+
162+
Tns.create_app(self.app_name, attributes={"--template": "[email protected]"},
163+
assert_success=False)
164+
res_path = os.path.join(self.app_name, 'app', 'App_Resources')
165+
assert File.exists(res_path), "App Resouces not added by {N} CLI if missing in template"
166+
158167
def test_400_create_project_with_wrong_template_path(self):
159168
"""--template should not create project if value is no npm installable"""
160169

0 commit comments

Comments
 (0)