реализовал тесты на получение имени профиля при установке

This commit is contained in:
rzaitov 2013-11-14 14:55:17 +04:00
parent 7c11a708f0
commit 826140a7eb
3 changed files with 29 additions and 4 deletions

View File

@ -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

View File

@ -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)