add graph flow test
[vfc/nfvo/lcm.git] / lcm / workflows / graphflow / tests / task_tests.py
1 # Copyright 2018 ZTE Corporation.
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 from lcm.workflows.graphflow.task.async_task import AsyncTask
16 from lcm.workflows.graphflow.task.sync_task import SyncTask
17 from lcm.workflows.graphflow.task.lcm_async_rest_task import LcmASyncRestTask
18 import logging
19
20 logger = logging.getLogger(__name__)
21
22
23 class CreateSynVNF(SyncTask):
24     def __init__(self, *args):
25         super(CreateSynVNF, self).__init__(*args)
26
27     def run(self):
28         logger.debug("test CreateSynVNF %s" % self.key)
29         return self.FINISHED, {}
30
31
32 class CreateAsynVNF(AsyncTask):
33     def __init__(self, *args):
34         super(CreateAsynVNF, self).__init__(*args)
35
36     def run(self):
37         logger.debug("test CreateAsynVNF %s" % self.key)
38         return self.PROCESSING, None
39
40     def get_ext_status(self):
41         return self.FINISHED
42
43
44 class CreateASynRestVNF(LcmASyncRestTask):
45
46     def __init__(self, *args):
47         super(CreateASynRestVNF, self).__init__(*args)
48         self.url = "/api/nslcm/v1/vnfs"
49         self.method = self.POST