diff --git a/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py index 4b31f80..535f44a 100644 --- a/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/InstallProfileCommandBuilder.py @@ -5,7 +5,10 @@ from parsers.InstallProfileParser import InstallProfileParser class InstallProfileCommandBuilder: - def __init__(self): + def __init__(self, profileFilePrefix): + assert profileFilePrefix is not None + + self.profileFilePrefix = profileFilePrefix self.profileStorageDir = '~/Library/MobileDevice/Provisioning Profiles/' def isInstallProfile(self, line): @@ -31,7 +34,13 @@ class InstallProfileCommandBuilder: return command def getDestinationPath(self, sourcePath): - profileFileName = os.path.basename(sourcePath) - destination = os.path.join(self.profileStorageDir, profileFileName) + dstProfileFileName = self.fetchDstFileName(sourcePath) + dstProfilePath = os.path.join(self.profileStorageDir, dstProfileFileName) - return destination + return dstProfilePath + + def fetchDstFileName(self, srcFilePath): + profileFileName = os.path.basename(srcFilePath) + profileFileName = '{0}.{1}'.format(self.profileFilePrefix, profileFileName) + + return profileFileName diff --git a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py new file mode 100644 index 0000000..13c5656 --- /dev/null +++ b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileBuilder.py @@ -0,0 +1,16 @@ +import unittest +from CommandBuilders.InstallProfileCommandBuilder import InstallProfileCommandBuilder + + +class TestInstallProfileBuilder(unittest.TestCase): + def setUp(self): + self.prefix = 'MyProject' + self.builder = InstallProfileCommandBuilder(self.prefix) + + def test_dstFileName(self): + dstFileName = self.builder.fetchDstFileName('/Some/Path/MyProfile.ext') + self.assertEqual(dstFileName, '{0}.MyProfile.ext'.format(self.prefix)) + + def test_dstPath(self): + dstPath = self.builder.getDestinationPath('/Some/Path/MyProfile.ext') + self.assertEqual('~/Library/MobileDevice/Provisioning Profiles/{0}.MyProfile.ext'.format(self.prefix), dstPath) \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py b/scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileParser.py similarity index 100% rename from scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfile.py rename to scripts/TouchinBuild/Tests/UnitTests/InstallProfile/test_installProfileParser.py