• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2import os.path
3
4from acls_check.acl_check import acl_check_main
5from devicetest.api import Asserts
6
7from test_case import ITestCase
8
9
10class ACLCheck(ITestCase):
11
12    def __init__(self, controllers):
13        super().__init__(controllers)
14        self.native_sa = os.path.join(os.path.dirname(self.testcases_path), 'acls_check', 'native_sa.log')
15
16    def setup(self):
17        self.step('前置条件1:ACL check 开始')
18
19    def process(self):
20        self.step('步骤1:clear native_sa.log first')
21        # 先删除文件内容
22        if os.path.exists(self.native_sa):
23            self.step('{} exist, delete before test'.format(self.native_sa))
24            with open(self.native_sa, 'w') as f:
25                f.write('')
26        self.step('步骤2:call acls_check.acl_check.py...')
27        acl_check_main(self.device_name)
28        self.step('步骤3:{} exist?:{}'.format(self.native_sa, os.path.exists(self.native_sa)))
29        with open(self.native_sa, mode='r', encoding='utf-8', errors='ignore') as f:
30            f.seek(0)
31            acl_result = f.read()
32        self.asserts.assert_not_in('ACL check failed', acl_result)
33
34    def teardown(self):
35        self.step('收尾:ACL check finish')
36