1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright (c) 2021 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15import unittest 16 17from blocks_manager import BlocksManager 18from transfers_manager import ActionInfo 19from transfers_manager import ActionType 20 21 22class TestUtils(unittest.TestCase): 23 24 def setUp(self): 25 print("set up") 26 27 def tearDown(self): 28 print("tear down") 29 30 def test_blocks_manager(self): 31 """ 32 Cases for BlocksManager 33 :return: 34 """ 35 bm1 = BlocksManager("5-10") 36 bm2 = BlocksManager("5-9") 37 check_re = bm1 == bm2 38 self.assertEqual(check_re, False) 39 40 check_re2 = bm1.get_map_within(bm2).range_data 41 self.assertEqual(check_re2, (0, 5)) 42 43 def test_action_info(self): 44 """ 45 Cases for ActionInfo 46 :return: 47 """ 48 bm1 = BlocksManager("5-10") 49 bm2 = BlocksManager("5-9") 50 action_info = ActionInfo( 51 ActionType.NEW, "test.txt", "test.txt", bm1, bm2) 52 check_re = action_info.net_stash_change() 53 self.assertEqual(check_re, 0) 54