blob: 15c1dbc76e3c3298f464215bcc77858c5a370e53 [file] [log] [blame]
David Bainbridge152bf5a2019-10-07 18:38:32 +00001# 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 Williamsa8fe75a2020-01-10 14:25:27 -070014
15from __future__ import absolute_import
16
David Bainbridge152bf5a2019-10-07 18:38:32 +000017from robot.libraries.BuiltIn import BuiltIn
18
Zack Williamsa8fe75a2020-01-10 14:25:27 -070019
David Bainbridge152bf5a2019-10-07 18:38:32 +000020class 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 Williamsa8fe75a2020-01-10 14:25:27 -070030 if key not in self.test_status:
David Bainbridge152bf5a2019-10-07 18:38:32 +000031 BuiltIn().fail("required test case can't be found: '%s'" % name)
32
Zack Williamsa8fe75a2020-01-10 14:25:27 -070033 if self.test_status[key] != "PASS":
David Bainbridge152bf5a2019-10-07 18:38:32 +000034 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"]