David Bainbridge | 152bf5a | 2019-10-07 18:38:32 +0000 | [diff] [blame] | 1 | # Copyright 2019 the original author or authors. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 14 | |
| 15 | from __future__ import absolute_import |
| 16 | |
David Bainbridge | 152bf5a | 2019-10-07 18:38:32 +0000 | [diff] [blame] | 17 | from robot.libraries.BuiltIn import BuiltIn |
| 18 | |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 19 | |
David Bainbridge | 152bf5a | 2019-10-07 18:38:32 +0000 | [diff] [blame] | 20 | class DependencyLibrary(object): |
| 21 | ROBOT_LISTENER_API_VERSION = 2 |
| 22 | ROBOT_LIBRARY_SCOPE = "GLOBAL" |
| 23 | |
| 24 | def __init__(self): |
| 25 | self.ROBOT_LIBRARY_LISTENER = self |
| 26 | self.test_status = {} |
| 27 | |
| 28 | def require_test_case(self, name): |
| 29 | key = name.lower() |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 30 | if key not in self.test_status: |
David Bainbridge | 152bf5a | 2019-10-07 18:38:32 +0000 | [diff] [blame] | 31 | BuiltIn().fail("required test case can't be found: '%s'" % name) |
| 32 | |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 33 | if self.test_status[key] != "PASS": |
David Bainbridge | 152bf5a | 2019-10-07 18:38:32 +0000 | [diff] [blame] | 34 | BuiltIn().fail("required test case failed: '%s'" % name) |
| 35 | |
| 36 | return True |
| 37 | |
| 38 | def _end_test(self, name, attrs): |
| 39 | self.test_status[name.lower()] = attrs["status"] |