| 1 |
import pytest |
| 2 |
|
| 3 |
from .conftest import ( |
| 4 |
LEAP_15_5, |
| 5 |
TUMBLEWEED, |
| 6 |
) |
| 7 |
|
| 8 |
|
| 9 |
CONTAINER_IMAGES = [TUMBLEWEED] |
| 10 |
|
| 11 |
|
| 12 |
def test_does_nothing_when_product_correct(auto_container_per_test): |
| 13 |
previous_contents = auto_container_per_test.connection.file( |
| 14 |
"/etc/products.d" |
| 15 |
).listdir() |
| 16 |
auto_container_per_test.connection.run_expect( |
| 17 |
[0], ". /bin/functions.sh && suseSetupProduct" |
| 18 |
) |
| 19 |
assert auto_container_per_test.connection.file("/etc/products.d").listdir() == previous_contents |
| 20 |
|
| 21 |
|
| 22 |
@pytest.mark.parametrize( |
| 23 |
"container_per_test,product_name", |
| 24 |
( |
| 25 |
(TUMBLEWEED, "openSUSE.prod"), |
| 26 |
(LEAP_15_5, "Leap.prod"), |
| 27 |
), |
| 28 |
indirect=["container_per_test"], |
| 29 |
) |
| 30 |
def test_sets_baseproduct_from_etc_os_release(container_per_test, product_name): |
| 31 |
assert not container_per_test.connection.file("/etc/SuSE-brand").exists |
| 32 |
|
| 33 |
container_per_test.connection.run_expect([0], "rm /etc/products.d/baseproduct") |
| 34 |
container_per_test.connection.run_expect( |
| 35 |
[0], ". /bin/functions.sh && suseSetupProduct" |
| 36 |
) |
| 37 |
|
| 38 |
assert container_per_test.connection.file("/etc/products.d/baseproduct").exists |
| 39 |
assert container_per_test.connection.file("/etc/products.d/baseproduct").is_symlink |
| 40 |
assert container_per_test.connection.file("/etc/products.d/baseproduct").linked_to == "/etc/products.d/" + product_name |
| 41 |
|
| 42 |
|
| 43 |
def test_sets_baseproduct_with_weird_os_release(auto_container_per_test): |
| 44 |
assert not auto_container_per_test.connection.file( |
| 45 |
"/etc/SuSE-brand" |
| 46 |
).exists |
| 47 |
auto_container_per_test.connection.run_expect( |
| 48 |
[0], "rm /etc/products.d/baseproduct" |
| 49 |
) |
| 50 |
auto_container_per_test.connection.run_expect( |
| 51 |
[0], |
| 52 |
"""cat <<EOF > /etc/os-release |
| 53 |
NAME=openSUSE Tumbleweed |
| 54 |
ID="opensuse-tumbleweed" |
| 55 |
ID_LIKE="opensuse suse" |
| 56 |
EOF |
| 57 |
""", |
| 58 |
) |
| 59 |
|
| 60 |
auto_container_per_test.connection.run_expect( |
| 61 |
[0], ". /bin/functions.sh && suseSetupProduct" |
| 62 |
) |
| 63 |
assert auto_container_per_test.connection.file( |
| 64 |
"/etc/products.d/baseproduct" |
| 65 |
).exists |
| 66 |
assert auto_container_per_test.connection.file( |
| 67 |
"/etc/products.d/baseproduct" |
| 68 |
).is_symlink |
| 69 |
assert ( |
| 70 |
auto_container_per_test.connection.file( |
| 71 |
"/etc/products.d/baseproduct" |
| 72 |
).linked_to == "/etc/products.d/openSUSE.prod" |
| 73 |
) |
| 74 |
|
| 75 |
|
| 76 |
def test_sets_baseproduct_from_prod_files(auto_container_per_test): |
| 77 |
auto_container_per_test.connection.run_expect( |
| 78 |
[0], |
| 79 |
"""rm /etc/products.d/baseproduct |
| 80 |
rm /etc/products.d/openSUSE.prod |
| 81 |
touch /etc/products.d/10.prod |
| 82 |
touch /etc/products.d/20.prod |
| 83 |
""", |
| 84 |
) |
| 85 |
|
| 86 |
auto_container_per_test.connection.run_expect( |
| 87 |
[0], ". /bin/functions.sh && suseSetupProduct" |
| 88 |
) |
| 89 |
assert auto_container_per_test.connection.file( |
| 90 |
"/etc/products.d/baseproduct" |
| 91 |
).exists |
| 92 |
assert auto_container_per_test.connection.file( |
| 93 |
"/etc/products.d/baseproduct" |
| 94 |
).is_symlink |
| 95 |
assert ( |
| 96 |
auto_container_per_test.connection.file( |
| 97 |
"/etc/products.d/baseproduct" |
| 98 |
).linked_to == "/etc/products.d/20.prod" |
| 99 |
) |