• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 Huawei Technologies Co., Ltd
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.
14# ============================================================================
15
16"""Component interfaces."""
17
18
19class IComponent:
20    """Component interfaces."""
21
22    def __init__(self, verification_set):
23        self.verification_set = verification_set
24
25    def __call__(self):
26        raise NotImplementedError
27
28
29class IDataComponent(IComponent):
30    """Create inputs for verification_set."""
31
32    def __call__(self):
33        raise NotImplementedError
34
35
36class IBuilderComponent(IComponent):
37    """Build system under test."""
38
39    def __call__(self):
40        raise NotImplementedError
41
42
43class IExectorComponent(IComponent):
44    """Execute sut, take (function, input) pairs as input."""
45
46    def __init__(self, verification_set, function, inputs):
47        super(IExectorComponent, self).__init__(verification_set)
48        self.function = function
49        self.inputs = inputs
50
51    def __call__(self):
52        raise NotImplementedError
53
54
55class IVerifierComponent(IComponent):
56    """Verify sut result, take (expect, result) pairs as input."""
57
58    def __init__(self, verification_set, expect, result):
59        super(IVerifierComponent, self).__init__(verification_set)
60        self.expect = expect
61        self.func_result = result
62
63    def __call__(self):
64        raise NotImplementedError
65
66
67class IFIPolicyComponent(IComponent):
68    """Combine functions/inputs."""
69
70    def __init__(self, verification_set, function, inputs):
71        super(IFIPolicyComponent, self).__init__(verification_set)
72        self.function = function
73        self.inputs = inputs
74
75    def __call__(self):
76        raise NotImplementedError
77
78
79class IERPolicyComponent(IComponent):
80    """Combine expects and results."""
81
82    def __init__(self, verification_set, expect, result):
83        super(IERPolicyComponent, self).__init__(verification_set)
84        self.expect = expect
85        self.result = result
86
87    def __call__(self):
88        raise NotImplementedError
89
90
91class IFacadeComponent(IComponent):
92    """Adapt verification_set."""
93
94    def __call__(self):
95        raise NotImplementedError
96