Skip to content

Add angular/ng template tests #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions core/tns/tns.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ def create_app(app_name, path=None, app_id=None, copy_from=None, template=None,
if app_id is not None:
command += " --appid " + app_id

# By default --copy-from template-hello-world
if copy_from is not None:
command += " --copy-from " + copy_from
else:
command += " --copy-from " + SUT_ROOT_FOLDER + os.path.sep + "template-hello-world"
if template is None:
# By default --copy-from template-hello-world
if copy_from is not None:
command += " --copy-from " + copy_from
else:
command += " --copy-from " + SUT_ROOT_FOLDER + os.path.sep + "template-hello-world"

if template is not None:
command += " --template " + template
Expand Down
53 changes: 53 additions & 0 deletions tests/build/build_android_ng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import unittest

from core.osutils.command import run
from core.osutils.file import File
from core.osutils.folder import Folder
from core.settings.settings import ANDROID_RUNTIME_PATH, TNS_PATH, \
ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_PATH, ANDROID_KEYSTORE_ALIAS_PASS
from core.tns.tns import Tns


class BuildAndroidNG(unittest.TestCase):

@classmethod
def setUpClass(cls):
Folder.cleanup('./TNS_App')
output = run(TNS_PATH + " create TNS_App --ng")
assert "successfully created" in output
Tns.platform_add(
platform="android",
path="TNS_App",
framework_path=ANDROID_RUNTIME_PATH)

def setUp(self):

print ""
print "#####"
print self.id()
print "#####"
print ""

def tearDown(self):
pass

@classmethod
def tearDownClass(cls):
Folder.cleanup('./TNS_App')

def test_010_build_android_ng_project(self):
Tns.build(platform="android", path="TNS_App")
assert File.exists("TNS_App/platforms/android/build/outputs/apk/TNSApp-debug.apk")

def test_210_build_android_ng_project(self):
output = run(TNS_PATH + " build android --keyStorePath " + ANDROID_KEYSTORE_PATH +
" --keyStorePassword " + ANDROID_KEYSTORE_PASS +
" --keyStoreAlias " + ANDROID_KEYSTORE_ALIAS +
" --keyStoreAliasPassword " + ANDROID_KEYSTORE_ALIAS_PASS +
" --release --path TNS_App")

assert "Project successfully prepared" in output
assert "BUILD SUCCESSFUL" in output

assert "Project successfully built" in output
assert File.exists("TNS_App/platforms/android/build/outputs/apk/TNSApp-release.apk")
56 changes: 56 additions & 0 deletions tests/build/build_ios_ng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import unittest

from core.osutils.command import run
from core.osutils.file import File
from core.osutils.folder import Folder
from core.settings.settings import IOS_RUNTIME_SYMLINK_PATH, TNS_PATH
from core.tns.tns import Tns
from core.xcode.xcode import Xcode


class BuildiOSNG(unittest.TestCase):

@classmethod
def setUpClass(cls):
Xcode.cleanup_cache()
Folder.cleanup('./TNS_App')

output = run(TNS_PATH + " create TNS_App --ng")
assert "successfully created" in output
Tns.platform_add(
platform="ios",
path="TNS_App",
framework_path=IOS_RUNTIME_SYMLINK_PATH, symlink=True)

def setUp(self):
print ""
print "#####"
print self.id()
print "#####"
print ""

def tearDown(self):
pass

@classmethod
def tearDownClass(cls):
Folder.cleanup('./TNS_App')

def test_010_build_ios_ng_project(self):
output = run(TNS_PATH + " build ios --path TNS_App")
assert "Project successfully prepared" in output
assert "build/emulator/TNSApp.app" in output
assert "** BUILD SUCCEEDED **" in output
assert "Project successfully built" in output
assert File.exists("TNS_App/platforms/ios/build/emulator/TNSApp.app")

def test_210_build_ios_ng_project_release_fordevice(self):
output = run(TNS_PATH +
" build ios --path TNS_App --for-device --release")
assert "Project successfully prepared" in output
assert "CONFIGURATION Release" in output
assert "CodeSign" in output
assert "build/device/TNSApp.app" in output
assert "** BUILD SUCCEEDED **" in output
assert "Project successfully built" in output
assert File.exists("TNS_App/platforms/ios/build/device/TNSApp.ipa")
63 changes: 63 additions & 0 deletions tests/build/create_ng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import unittest

from nose_parameterized import parameterized

from core.osutils.command import run
from core.osutils.folder import Folder
from core.settings.settings import TNS_PATH
from core.tns.tns import Tns


class CreateNG(unittest.TestCase):

def setUp(self):
print ""
print "#####"
print self.id()
print "#####"
print ""

Folder.cleanup('./TNS_App')

def tearDown(self):
Folder.cleanup('./TNS_App')

def assert_angular_project(self):
output = run("cat TNS_App/package.json")
assert "angular2" in output
assert "nativescript-angular" in output
assert "tns-core-modules" in output
assert "nativescript-dev-typescript" in output

assert Folder.exists("TNS_App/node_modules/angular2")
assert Folder.exists("TNS_App/node_modules/nativescript-angular")
assert Folder.exists("TNS_App/node_modules/nativescript-dev-typescript")
assert Folder.exists("TNS_App/node_modules/tns-core-modules")

assert Folder.exists("TNS_App/hooks")
assert Folder.exists("TNS_App/app/App_Resources")

def test_101_create_ng_project(self):
output = run(TNS_PATH + " create TNS_App --ng")
assert "successfully created" in output
self.assert_angular_project()

@parameterized.expand([
"tns-template-hello-world-ng",
"https://github.com/NativeScript/template-hello-world-ng.git",
"angular",
"ng",
])
def test_102_create_project_with_template_ng(self, template_source):
Tns.create_app(app_name="TNS_App", template=template_source)
self.assert_angular_project()

def test_401_create_project_with_template_no_value(self):
output = run(TNS_PATH + " create TNS_App --template")
assert "successfully created" not in output
assert "requires non-empty value" in output

def test_402_create_project_with_template_and_ng(self):
output = run(TNS_PATH + " create TNS_App --template --ng")
assert "successfully created" not in output
assert "requires non-empty value" in output
55 changes: 35 additions & 20 deletions tests/build/prepare_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


class PrepareAndroid(unittest.TestCase):

def setUp(self):
print ""
print "#####"
Expand Down Expand Up @@ -66,7 +67,40 @@ def test_002_prepare_android_inside_project(self):
assert not File.exists(
'TNS_App/platforms/android/src/main/assets/app/tns_modules/application/application.ios.js')

def test_010_prepare_android_tns_core_modules(self):
def test_010_prepare_android_ng_project(self):
output = run(TNS_PATH + " create TNS_App --ng")
assert "successfully created" in output
Tns.platform_add(
platform="android",
path="TNS_App",
framework_path=ANDROID_RUNTIME_PATH)
Tns.prepare(platform="android", path="TNS_App")

assert Folder.exists(
'TNS_App/platforms/android/src/main/assets/app/tns_modules/angular2')
assert Folder.exists(
'TNS_App/platforms/android/src/main/assets/app/tns_modules/nativescript-angular')

def test_200_prepare_android_patform_not_added(self):
Tns.create_app(app_name="TNS_App")
output = run(TNS_PATH + " prepare android --path TNS_App")
assert "Copying template files..." in output
assert "Project successfully created." in output
assert "Project successfully prepared" in output
assert File.exists(
'TNS_App/platforms/android/src/main/assets/app/tns_modules/xml/xml.js')

def test_201_prepare_xml_error(self):
Tns.create_app(app_name="TNS_App")
File.replace("TNS_App/app/main-page.xml", "</Page>", "</Page")
output = run(TNS_PATH + " prepare android --path TNS_App")
assert "Copying template files..." in output
assert "Project successfully created." in output
assert "Project successfully prepared" in output
assert "main-page.xml has syntax errors." in output
assert "unclosed xml attribute" in output

def test_210_prepare_android_tns_core_modules(self):
Tns.create_app(
app_name="TNS_App",
copy_from=SUT_ROOT_FOLDER + "/QA-TestApps/tns-modules-app/app")
Expand Down Expand Up @@ -108,25 +142,6 @@ def test_010_prepare_android_tns_core_modules(self):
"tns_modules/application/application-common.js")
assert "require(\"globals\"); // test" in output

def test_200_prepare_android_patform_not_added(self):
Tns.create_app(app_name="TNS_App")
output = run(TNS_PATH + " prepare android --path TNS_App")
assert "Copying template files..." in output
assert "Project successfully created." in output
assert "Project successfully prepared" in output
assert File.exists(
'TNS_App/platforms/android/src/main/assets/app/tns_modules/xml/xml.js')

def test_201_prepare_xml_error(self):
Tns.create_app(app_name="TNS_App")
File.replace("TNS_App/app/main-page.xml", "</Page>", "</Page")
output = run(TNS_PATH + " prepare android --path TNS_App")
assert "Copying template files..." in output
assert "Project successfully created." in output
assert "Project successfully prepared" in output
assert "main-page.xml has syntax errors." in output
assert "unclosed xml attribute" in output

def test_300_prepare_android_remove_old_files(self):
Tns.create_app_platform_add(
app_name="TNS_App",
Expand Down
79 changes: 47 additions & 32 deletions tests/build/prepare_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


class PrepareiOS(unittest.TestCase):

@classmethod
def setUpClass(cls):
if CURRENT_OS != OSType.OSX:
Expand All @@ -28,7 +29,7 @@ def setUp(self):
Folder.cleanup('./TNS_App')

def tearDown(self):
pass
Folder.cleanup('./TNS_App')

def test_001_prepare_ios(self):
Tns.create_app_platform_add(app_name="TNS_App", platform="ios",
Expand All @@ -47,38 +48,19 @@ def test_001_prepare_ios(self):
assert not File.exists(
'TNS_App/platforms/ios/TNSApp/app/tns_modules/application/application.ios.js')

def test_010_prepare_ios_tns_core_modules(self):
Tns.create_app(app_name="TNS_App", copy_from="data/projects/helloworld-1.2.1/app")
Tns.platform_add(platform="ios", path="TNS_App",
framework_path=IOS_RUNTIME_SYMLINK_PATH, symlink=True)

# Make a change in tns-core-modules to verify they are not overwritten.
File.replace("TNS_App/node_modules/tns-core-modules/application/application-common.js",
"(\"globals\");",
"(\"globals\"); // test")

# Verify tns-core-modules are copied to the native project, not app's tns_modules.
for i in range(1, 3):
print "prepare number: " + str(i)

output = run(TNS_PATH + " prepare ios --path TNS_App")
assert "You have tns_modules dir in your app folder" in output
assert "Project successfully prepared" in output

output = run("cat TNS_App/app/tns_modules/package.json")
assert "\"version\": \"1.2.1\"," in output

output = run("cat TNS_App/node_modules/tns-core-modules/package.json")
assert "\"version\": \"1.2.1\"," not in output
output = run("cat TNS_App/node_modules/" +
"tns-core-modules/application/application-common.js")
assert "require(\"globals\"); // test" in output
def test_010_prepare_android_ng_project(self):
output = run(TNS_PATH + " create TNS_App --ng")
assert "successfully created" in output
Tns.platform_add(
platform="ios",
path="TNS_App",
framework_path=IOS_RUNTIME_SYMLINK_PATH, symlink=True)
Tns.prepare(platform="ios", path="TNS_App")

output = run("cat TNS_App/platforms/ios/TNSApp/app/tns_modules/package.json")
assert "\"version\": \"1.2.1\"," not in output
output = run("cat TNS_App/platforms/ios/" +
"TNSApp/app/tns_modules/application/application-common.js")
assert "require(\"globals\"); // test" in output
assert Folder.exists(
'TNS_App/platforms/ios/TNSApp/app/tns_modules/angular2')
assert Folder.exists(
'TNS_App/platforms/ios/TNSApp/app/tns_modules/nativescript-angular')

def test_200_prepare_additional_appresources(self):
Tns.create_app_platform_add(app_name="TNS_App", platform="ios",
Expand Down Expand Up @@ -119,6 +101,39 @@ def test_201_prepare_ios_platform_not_added(self):
assert File.exists(
'TNS_App/platforms/ios/TNSApp/app/tns_modules/application/application.js')

def test_210_prepare_ios_tns_core_modules(self):
Tns.create_app(app_name="TNS_App", copy_from="data/projects/helloworld-1.2.1/app")
Tns.platform_add(platform="ios", path="TNS_App",
framework_path=IOS_RUNTIME_SYMLINK_PATH, symlink=True)

# Make a change in tns-core-modules to verify they are not overwritten.
File.replace("TNS_App/node_modules/tns-core-modules/application/application-common.js",
"(\"globals\");",
"(\"globals\"); // test")

# Verify tns-core-modules are copied to the native project, not app's tns_modules.
for i in range(1, 3):
print "prepare number: " + str(i)

output = run(TNS_PATH + " prepare ios --path TNS_App")
assert "You have tns_modules dir in your app folder" in output
assert "Project successfully prepared" in output

output = run("cat TNS_App/app/tns_modules/package.json")
assert "\"version\": \"1.2.1\"," in output

output = run("cat TNS_App/node_modules/tns-core-modules/package.json")
assert "\"version\": \"1.2.1\"," not in output
output = run("cat TNS_App/node_modules/" +
"tns-core-modules/application/application-common.js")
assert "require(\"globals\"); // test" in output

output = run("cat TNS_App/platforms/ios/TNSApp/app/tns_modules/package.json")
assert "\"version\": \"1.2.1\"," not in output
output = run("cat TNS_App/platforms/ios/" +
"TNSApp/app/tns_modules/application/application-common.js")
assert "require(\"globals\"); // test" in output

def test_300_prepare_ios_preserve_case(self):
Tns.create_app_platform_add(app_name="TNS_App", platform="ios",
framework_path=IOS_RUNTIME_SYMLINK_PATH, symlink=True)
Expand Down
Loading