Pin pip to 20.3.3 and disable tmpfs in DIB
[ta/build-tools.git] / tools / releasereader_test.py
1 # Copyright 2019 Nokia
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 import pytest
16 import mock
17
18 from tools.releasereader import ReleaseReader
19 from tools.executor import Result
20
21
22 @pytest.mark.parametrize('curr_release, next_release', [
23     ('ABC_D19-0', 'ABC_D19-1'),
24     ('ABC_D19-19', 'ABC_D19-20'),
25     ('ABC_D19A-1', 'ABC_D19A-2'),
26     ('ABC_D19A-1.0', 'ABC_D19A-1.1'),
27     ('ABC_D20-0', 'ABC_D20-1')
28 ])
29 @mock.patch('tools.releasereader.Executor')
30 def test_next_release(mock_exec, curr_release, next_release):
31     mock_exec.return_value.run.return_value = Result(0, curr_release + '\n', '')
32     assert ReleaseReader('test-path').get_next_release_label() == next_release
33     mock_exec.assert_called_once_with(chdir='test-path')
34     mock_exec.return_value.run.assert_called_once_with(['git', 'describe', '--tags', '--abbrev=0'])