|
| 1 | +# Databricks CLI |
| 2 | +# Copyright 2022 Databricks, Inc. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"), except |
| 5 | +# that the use of services to which certain application programming |
| 6 | +# interfaces (each, an "API") connect requires that the user first obtain |
| 7 | +# a license for the use of the APIs from Databricks, Inc. ("Databricks"), |
| 8 | +# by creating an account at www.databricks.com and agreeing to either (a) |
| 9 | +# the Community Edition Terms of Service, (b) the Databricks Terms of |
| 10 | +# Service, or (c) another written agreement between Licensee and Databricks |
| 11 | +# for the use of the APIs. |
| 12 | +# |
| 13 | +# You may not use this file except in compliance with the License. |
| 14 | +# You may obtain a copy of the License at |
| 15 | +# |
| 16 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +# |
| 18 | +# Unless required by applicable law or agreed to in writing, software |
| 19 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | +# See the License for the specific language governing permissions and |
| 22 | +# limitations under the License. |
| 23 | + |
| 24 | +import pytest |
| 25 | + |
| 26 | +import databricks_cli.version as version |
| 27 | + |
| 28 | + |
| 29 | +def test_is_release_version_defaults_to_current_version(): |
| 30 | + # Not specifying a version explicitly implies testing the current version. |
| 31 | + assert version.is_release_version() == version.is_release_version(version.version) |
| 32 | + |
| 33 | + |
| 34 | +def test_is_release_version(): |
| 35 | + # Release versions |
| 36 | + assert version.is_release_version("0.16.0") |
| 37 | + assert version.is_release_version("0.16.8") |
| 38 | + assert version.is_release_version("0.16.1111") |
| 39 | + assert version.is_release_version("0.17.0") |
| 40 | + assert version.is_release_version("1.0.0") |
| 41 | + |
| 42 | + # Development versions |
| 43 | + assert not version.is_release_version("0.16.0.dev0") |
| 44 | + assert not version.is_release_version("0.16.8.dev0") |
| 45 | + assert not version.is_release_version("0.16.1111.dev1") |
| 46 | + assert not version.is_release_version("0.17.0.dev") |
| 47 | + assert not version.is_release_version("1.0.0.x") |
| 48 | + |
| 49 | + # Malformed version |
| 50 | + with pytest.raises(ValueError): |
| 51 | + version.is_release_version("foobar") |
| 52 | + |
| 53 | + with pytest.raises(ValueError): |
| 54 | + version.is_release_version("1.0.0dev0") |
| 55 | + |
| 56 | + with pytest.raises(ValueError): |
| 57 | + version.is_release_version("1.0.0.") |
| 58 | + |
| 59 | + with pytest.raises(ValueError): |
| 60 | + version.is_release_version("1.0.0.!") |
| 61 | + |
| 62 | + |
| 63 | +def test_next_development_version(): |
| 64 | + assert version.next_development_version("0.16.0") == "0.16.1.dev0" |
| 65 | + assert version.next_development_version("0.16.8") == "0.16.9.dev0" |
| 66 | + assert version.next_development_version("0.16.1111") == "0.16.1112.dev0" |
| 67 | + assert version.next_development_version("0.17.0") == "0.17.1.dev0" |
| 68 | + assert version.next_development_version("1.0.0") == "1.0.1.dev0" |
0 commit comments