Merge branch 'BS-16'

This commit is contained in:
rzaitov 2013-11-01 20:17:10 +04:00
commit 542c3cfc66
15 changed files with 117 additions and 10 deletions

View File

@ -0,0 +1,24 @@
from commands.TestflightCommand import TestflightCommand
from parser.TestflightParser import TestflightParser
class TestflightCommandBuilder:
def __init__(self):
pass
def isTestflight(self, line):
assert line is not None
parser = TestflightParser()
isValid = parser.isValidLine(line)
return isValid
def getCommandFor(self, line):
assert line is not None
parser = TestflightParser()
result = parser.parseLine(line)
command = TestflightCommand(result['path'], result['api_token'], result['team_token'], result['notes'])
return command

View File

@ -0,0 +1,8 @@
from CommandBuilders.TestflightCommandBuilder import TestflightCommandBuilder
line = "publish 'Output/Appstore/Artifacts/BuildSample-1.2.3.ipa' to testflight notes = 'Hello' api_token = '0e6925075d4fc10fed0e7bbf43fa6894_NjQ0OTI2MjAxMi0wOS0yNSAxMTo0MDozNi40OTY5MjU' team_token = 'c5c3cf7a6dae2bea4382dfbd181a2075_Mjc4ODkwMjAxMy0wOS0yOSAxNDowOTo1OC40Mzg5MTY'"
builder = TestflightCommandBuilder()
command = builder.getCommandFor(line)
command.execute()

View File

@ -0,0 +1 @@
__author__ = 'rzaitov'

View File

@ -0,0 +1,28 @@
import unittest
from parser.TestflightParser import TestflightParser
class TesttestflightParser(unittest.TestCase):
def setUp(self):
self.parser = TestflightParser()
def test_isValid(self):
line = 'publish bla bla'
isValid = self.parser.isValidLine(line)
self.assertEqual(True, isValid)
def test_isNotValid(self):
line = '*publish'
isValid = self.parser.isValidLine(line)
self.assertEqual(False, isValid)
def test_validInput(self):
line = "publish '~/Dir/another dir/file.ipa' to testflight notes = 'hello world! 123' api_token = 'qwerty123' team_token = 'asdfg123'"
result = self.parser.parseLine(line)
self.assertEqual('~/Dir/another dir/file.ipa', result['path'])
self.assertEqual('hello world! 123', result['notes'])
self.assertEqual('qwerty123',result['api_token'])
self.assertEqual('asdfg123', result['team_token'])

View File

@ -1,7 +1,7 @@
from utils.TestflightPublisher import TestFlightPublisher
class PublishToTestFlightCommand:
class TestflightCommand:
def __init__(self, pathToFile, api_token, team_token, notes):
assert pathToFile is not None

View File

@ -14,7 +14,7 @@ class CreateBackupParser(LineParser):
folderNameRegexp = r"'(?P<folder>[^']+)'$"
regexpSource = self.startsWithKeywordToken('create backup for') + folderNameRegexp
regexpSource = self.startsWith('create backup for') + folderNameRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -16,7 +16,7 @@ class CleanBuildParser(LineParser):
filePathRegexp = r"'(?P<path>[./ a-zA-Z]+\.sln)'"
slnConfigRegexp = r"'(?P<config>[a-zA-Z|]+)'$"
regexpSource = self.startsWithKeywordToken(self.__commandToken) + filePathRegexp + self.keywordToken('for') + slnConfigRegexp
regexpSource = self.startsWith(self.__commandToken) + filePathRegexp + self.keywordToken('for') + slnConfigRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -15,7 +15,7 @@ class CopyLineParser(LineParser):
srcFileNameRegexp = r"'(?P<src>[^']+)'"
dstFileNameRegexp = r"'(?P<dst>[^']+)'$"
regexpSource = self.startsWithKeywordToken('copy') + srcFileNameRegexp + self.keywordToken('to') + dstFileNameRegexp
regexpSource = self.startsWith('copy') + srcFileNameRegexp + self.keywordToken('to') + dstFileNameRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -16,7 +16,7 @@ class InsideRemoveParser(LineParser):
filePathRegexp = r"'(?P<file>[./ a-zA-Z]+\.{0})'".format(self.__extension)
projectNameRegexp = r'(?P<project>[.a-zA-Z]+)'
regexpSource = self.startsWithKeywordToken('inside') + filePathRegexp + self.keywordToken('remove') + projectNameRegexp + self.endsWithKeywordToken('project')
regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('remove') + projectNameRegexp + self.endsWith('project')
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -18,7 +18,7 @@ class InsideSetParser(LineParser):
keyRegexp = r'(?P<key>[a-zA-Z]+)'
valueRegexp = r"'(?P<value>[^']+)'"
regexpSource = self.startsWithKeywordToken('inside') + filePathRegexp + self.keywordToken('set') + keyRegexp + self.keywordToken('to') + valueRegexp
regexpSource = self.startsWith('inside') + filePathRegexp + self.keywordToken('set') + keyRegexp + self.keywordToken('to') + valueRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -14,14 +14,18 @@ class LineParser:
assert keyword is not None
return r'\s+' + keyword + r'\s+'
def startsWithKeywordToken(self, keyword):
def startsWith(self, keyword):
assert keyword is not None
return r'^' + keyword + r'\s+'
def endsWithKeywordToken(self, keyword):
def endsWith(self, keyword):
assert keyword is not None
return r'\s+' + keyword + '$'
def than(self, keyword):
assert keyword is not None
return keyword + r'\s+'
def _guardMatch(self, match_object, source, regexpSource = None):
if match_object is None:
msg = 'Recognition exception: "{0}" for "{1}"'.format(source, regexpSource)

View File

@ -10,7 +10,7 @@ class MakeDirsParser(LineParser):
def parseLine(self, line):
pathRegexp = r"'(?P<path>[^']+)'$"
regexpSource = self.startsWithKeywordToken('create dirs') + pathRegexp
regexpSource = self.startsWith('create dirs') + pathRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -12,7 +12,7 @@ class ShParser(LineParser):
cmdTextRegexp = r'(?P<text>.*)'
regexpSource = self.startsWithKeywordToken('sh') + cmdTextRegexp
regexpSource = self.startsWith('sh') + cmdTextRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)

View File

@ -0,0 +1,41 @@
from parser.LineParser import LineParser
import re
class TestflightParser(LineParser):
def __init__(self):
LineParser.__init__(self)
def parseLine(self, line):
assert line is not None
notesRegexp = r"'(?P<notes>[^']+)'"
apiTokenRegexp = r"'(?P<api_token>[^']+)'"
teamTokenRegexp = r"'(?P<team_token>[^']+)'"
filePathRegexp = r"'(?P<path>[^']+)'"
regexpSource = self.startsWith('publish') + filePathRegexp + self.keywordToken('to') + self.than('testflight') + \
self.than('notes') + self.than('=') + notesRegexp + \
self.keywordToken('api_token') + self.than('=') + apiTokenRegexp + \
self.keywordToken('team_token') + self.than('=') + teamTokenRegexp
regexp = re.compile(regexpSource, re.UNICODE)
match = regexp.match(line)
self._guardMatch(match, line, regexpSource)
path = match.group('path')
notes = match.group('notes')
apiToken = match.group('api_token')
teamToken = match.group('team_token')
return {
'path': path,
'notes': notes,
'api_token': apiToken,
'team_token': teamToken
}
def isValidLine(self, line):
assert line is not None
return line.startswith('publish')

View File

@ -18,4 +18,5 @@ os.chdir(baseDir)
#import ManualTests.remove_project
#import ManualTests.infoplist_test
#import ManualTests.clean_test
import Tests.ManualTests.testflight_test