| 1 |
###################################################################### |
| 2 |
# |
| 3 |
# File: test/unit/test_apiver.py |
| 4 |
# |
| 5 |
# Copyright 2023 Backblaze Inc. All Rights Reserved. |
| 6 |
# |
| 7 |
# License https://www.backblaze.com/using_b2_code.html |
| 8 |
# |
| 9 |
###################################################################### |
| 10 |
import unittest |
| 11 |
|
| 12 |
import pytest |
| 13 |
|
| 14 |
|
| 15 |
@pytest.fixture |
| 16 |
def inject_apiver_int(request, apiver_int): |
| 17 |
request.cls.apiver_int = apiver_int |
| 18 |
|
| 19 |
|
| 20 |
@pytest.mark.usefixtures('inject_apiver_int') |
| 21 |
class UnitTestClass(unittest.TestCase): |
| 22 |
apiver_int: int |
| 23 |
|
| 24 |
@pytest.mark.apiver(to_ver=3) |
| 25 |
def test_passes_below_and_on_v3(self): |
| 26 |
assert self.apiver_int <= 3 |
| 27 |
|
| 28 |
@pytest.mark.apiver(from_ver=4) |
| 29 |
def test_passes_above_and_on_v4(self): |
| 30 |
assert self.apiver_int >= 4 |
| 31 |
|
| 32 |
@pytest.mark.apiver(3) |
| 33 |
def test_passes_only_on_v3(self): |
| 34 |
assert self.apiver_int == 3 |
| 35 |
|
| 36 |
@pytest.mark.apiver(4) |
| 37 |
def test_passes_only_on_v4(self): |
| 38 |
assert self.apiver_int == 4 |
| 39 |
|
| 40 |
@pytest.mark.apiver(3, 4) |
| 41 |
def test_passes_on_both_v3_and_v4(self): |
| 42 |
assert self.apiver_int in {3, 4} |
| 43 |
|
| 44 |
|
| 45 |
@pytest.mark.apiver(to_ver=3) |
| 46 |
def test_passes_below_and_on_v3(apiver_int): |
| 47 |
assert apiver_int <= 3 |
| 48 |
|
| 49 |
|
| 50 |
@pytest.mark.apiver(from_ver=4) |
| 51 |
def test_passes_above_and_on_v4(apiver_int): |
| 52 |
assert apiver_int >= 4 |
| 53 |
|
| 54 |
|
| 55 |
@pytest.mark.apiver(3) |
| 56 |
def test_passes_only_on_v3(apiver_int): |
| 57 |
assert apiver_int == 3 |
| 58 |
|
| 59 |
|
| 60 |
@pytest.mark.apiver(4) |
| 61 |
def test_passes_only_on_v4(apiver_int): |
| 62 |
assert apiver_int == 4 |
| 63 |
|
| 64 |
|
| 65 |
@pytest.mark.apiver(3, 4) |
| 66 |
def test_passes_on_both_v3_and_v4(apiver_int): |
| 67 |
assert apiver_int in {3, 4} |