Kiln » Unstable
Clone URL:  

Update bfiles tests to support testing the other extensions.

Changeset 2032dd08b000

Parent 86f4efeffc0a

by David Golub

Changes to one file · Browse files at 2032dd08b000 Showing diff from parent 86f4efeffc0a Diff from another changeset...

Change 1 of 4 Show Entire File tests/​kilntest.py Stacked
 
12
13
14
15
 
16
17
18
 
22
23
24
 
 
 
 
 
 
 
25
26
27
 
60
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
65
66
67
68
 
69
70
71
 
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
 
15
16
17
18
 
22
23
24
25
26
27
28
29
30
31
32
33
34
 
67
68
69
 
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 
114
115
116
 
 
 
 
 
 
 
 
 
 
 
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
@@ -12,7 +12,7 @@
 # not already exist when the test is initiated. The username and password  # given must have write access to that group.   -KILNAUTHPATH = '/code/kiln/2-0/extensions/kilnauth.py' +KILNEXTPATH = '/code/kiln/2-0/extensions'  KILNURL = 'http://localhost/FogBugz/kiln'  USER = 'test'  PASSWORD = 'tester' @@ -22,6 +22,13 @@
 # changes the home directory in the test script.  os.environ['HOME'] = os.path.expanduser('~' + getpass.getuser());   +# Paths for the individual extensions +KILNAUTHPATH = KILNEXTPATH + '/kilnauth.py' +GESTALTPATH = KILNEXTPATH + '/gestalt.py' +KILNPATHPATH = KILNEXTPATH + '/kilnpath.py' +BIGPUSHPATH = KILNEXTPATH + '/big-push.py' +KILNPATH = KILNEXTPATH + '/kiln.py' +  def api(url):   return KILNURL + '/api/1.0/' + url   @@ -60,12 +67,43 @@
  while slurp(api('Repo/%d' % ixRepo), dict(token=token))['sStatus'] != 'good':   time.sleep(0.1)   - return (KILNURL + '/Repo/Test/Test/test', ixRepo) + return (KILNURL + '/Repo/Test/Test/Test', ixRepo) + +def createtestbranch(hgt, token, ixParent): + projects = slurp(api('Project'), dict(token=token)) + + found = False + for project in projects: + if project['sName'] == 'Test': + ixProject = project['ixProject'] + for group in project['repoGroups']: + if group['sName'] == 'Test': + ixRepoGroup = group['ixRepoGroup'] + found = True + + if not found: + return None + + time.sleep(1) + while slurp(api('Repo/%d' % ixParent), dict(token=token))['sStatus'] != 'good': + time.sleep(0.1) + + repo = slurp(api('Repo/Create'), dict(sName='TestBranch', sDescription='test branch', ixRepoGroup=ixRepoGroup, ixParent=ixParent, fCentral=False, sDefaultPermission='write', token=token)) + ixRepo = repo['ixRepo'] + + hgt.asserttrue(isinstance(ixRepo, int), 'Create failed %s' % (str(ixRepo))) + + time.sleep(1) + while slurp(api('Repo/%d' % ixRepo), dict(token=token))['sStatus'] != 'good': + time.sleep(0.1) + + return (KILNURL + '/Repo/Test/Test/TestBranch', ixRepo)    def deletetest(hgt, token):   projects = slurp(api('Project'), dict(token=token))     found = False + foundBranch = False   for project in projects:   if project['sName'] == 'Test':   ixProject = project['ixProject'] @@ -76,14 +114,22 @@
  if repo['sName'] == 'Test':   ixRepo = repo['ixRepo']   found = True - if not found: - return None - slurp(api('Repo/%d/Delete' % ixRepo), dict(token=token), post=True) - - try: - while True: - slurp(api('Repo/%d' % ixRepo), dict(token=token)) - time.sleep(0.1) - except urllib2.HTTPError: - pass - + if repo['sName'] == 'TestBranch': + ixBranch = repo['ixRepo'] + foundBranch = True + if foundBranch: + slurp(api('Repo/%d/Delete' % ixBranch), dict(token=token), post=True) + try: + while True: + slurp(api('Repo/%d' % ixBranch), dict(token=token)) + time.sleep(0.1) + except urllib2.HTTPError: + pass + if found: + slurp(api('Repo/%d/Delete' % ixRepo), dict(token=token), post=True) + try: + while True: + slurp(api('Repo/%d' % ixRepo), dict(token=token)) + time.sleep(0.1) + except urllib2.HTTPError: + pass