Skip to content

Commit 42aa5dc

Browse files
authored
Random bug fixes (#132)
* fix bugs getting test of a run by name and id * convert maps to lists for py3
1 parent dfb85b9 commit 42aa5dc

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

testrail/client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _project_by_id(self, project_id):
6767

6868
# User Methods
6969
def users(self):
70-
return map(User, self.api.users())
70+
return list(map(User, self.api.users()))
7171

7272
@methdispatch
7373
def user(self):
@@ -95,7 +95,7 @@ def inactive_users(self):
9595

9696
# Suite Methods
9797
def suites(self):
98-
return map(Suite, self.api.suites(self._project_id))
98+
return list(map(Suite, self.api.suites(self._project_id)))
9999

100100
@methdispatch
101101
def suite(self):
@@ -133,7 +133,7 @@ def _delete_suite(self, obj):
133133

134134
# Milestone Methods
135135
def milestones(self):
136-
return map(Milestone, self.api.milestones(self._project_id))
136+
return list(map(Milestone, self.api.milestones(self._project_id)))
137137

138138
@methdispatch
139139
def milestone(self):
@@ -266,7 +266,7 @@ def _delete_run(self, obj):
266266

267267
# Case Methods
268268
def cases(self, suite):
269-
return map(Case, self.api.cases(self._project_id, suite.id))
269+
return list(map(Case, self.api.cases(self._project_id, suite.id)))
270270

271271
@methdispatch
272272
def case(self):
@@ -293,7 +293,7 @@ def _add_case(self, obj):
293293

294294
# Test Methods
295295
def tests(self, run):
296-
return map(Test, self.api.tests(run.id))
296+
return list(map(Test, self.api.tests(run.id)))
297297

298298
@methdispatch
299299
def test(self):
@@ -302,14 +302,14 @@ def test(self):
302302
@test.register(str)
303303
@test.register(unicode)
304304
@singleresult
305-
def _test_by_name(self, name):
306-
return filter(lambda t: t.name.lower() == name.lower(), self.tests())
305+
def _test_by_name(self, name, run):
306+
return filter(lambda t: t.title.lower() == name.lower(), self.tests(run))
307307

308308
@test.register(int)
309309
@singleresult
310310
def _test_by_id(self, test_id, run):
311311
return filter(
312-
lambda t: t.raw_data()['case_id'] == test_id, self.tests(run))
312+
lambda t: t.raw_data()['id'] == test_id, self.tests(run))
313313

314314
# Result Methods
315315
@methdispatch
@@ -336,11 +336,11 @@ def _add_result(self, obj):
336336
def _add_results(self, results):
337337
obj, value = results
338338
if isinstance(obj, Run):
339-
self.api.add_results(map(lambda x: x.raw_data(), value), obj.id)
339+
self.api.add_results(list(map(lambda x: x.raw_data(), value), obj.id))
340340

341341
# Section Methods
342342
def sections(self, suite=None):
343-
return map(Section, self.api.sections(suite_id=suite.id))
343+
return list(map(Section, self.api.sections(suite_id=suite.id)))
344344

345345
@methdispatch
346346
def section(self):
@@ -362,7 +362,7 @@ def _add_section(self, section):
362362

363363
# Status Methods
364364
def statuses(self):
365-
return map(Status, self.api.statuses())
365+
return list(map(Status, self.api.statuses()))
366366

367367
@methdispatch
368368
def status(self):
@@ -380,4 +380,4 @@ def _status_by_id(self, status_id):
380380
return filter(lambda s: s.id == status_id, self.statuses())
381381

382382
def configs(self):
383-
return ConfigContainer(map(Config, self.api.configs()))
383+
return ConfigContainer(list(map(Config, self.api.configs())))

testrail/entry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def name(self):
3232

3333
@property
3434
def runs(self):
35-
return map(EntryRun, self._content.get('runs'))
35+
return list(map(EntryRun, self._content.get('runs')))
3636

3737
@property
3838
def suite(self):

0 commit comments

Comments
 (0)