1#!/usr/bin/env python3 2# coding=utf-8 3 4# 5# Copyright (c) 2021 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19import sys 20import os 21 22sys.path.insert(0, os.environ.get('PYTEST_PYTESTPATH')) 23 24import unittest 25from distributed import * 26 27 28class DbinderTest(unittest.TestCase): 29 def setUp(self): 30 print('setUp') 31 self.result_path = get_result_dir(__file__) 32 self.suits_dir = os.path.abspath(os.path.dirname(__file__)) 33 self.manager = DeviceManager() 34 self.major = self.manager.PHONE1 35 self.angent_list = [self.manager.WATCH1, self.manager.PHONE2] 36 37 def test_dbinder(self): 38 major_target_name = "DbinderTest" 39 agent_target_name = "DbinderTestAgent" 40 41 distribute = Distribute(self.suits_dir, self.major, self.angent_list) 42 43 for agent in self.angent_list: 44 if not distribute.exec_agent(agent, agent_target_name): 45 create_empty_result_file(self.result_path, major_target_name) 46 return 47 48 distribute.exec_major(self.major, major_target_name) 49 50 source_path = "%s/%s.xml" % (self.major.test_path, major_target_name) 51 distribute.pull_result(self.major, source_path, self.result_path) 52 53 def tearDown(self): 54 print('tearDown') 55 56 57if __name__ == '__main__': 58 unittest.main() 59