|
| 1 | +from python_gardenlinux_lib.apt.parse_debsource import DebsrcFile |
| 2 | +import io |
| 3 | + |
| 4 | +test_data = """Package: vim |
| 5 | +Source: vim (2:9.1.0496-1) |
| 6 | +Version: 2:9.1.0496-1+b1 |
| 7 | +Architecture: amd64 |
| 8 | +Maintainer: Debian Vim Maintainers <[email protected]> |
| 9 | +Installed-Size: 3788 |
| 10 | +Depends: vim-common (= 2:9.1.0496-1), vim-runtime (= 2:9.1.0496-1), libacl1 (>= 2.2.23), libc6 (>= 2.38), libgpm2 (>= 1.20.7), libselinux1 (>= 3.1~), libsodium23 (>= 1.0.14), libtinfo6 (>= 6) |
| 11 | +Suggests: ctags, vim-doc, vim-scripts |
| 12 | +Provides: editor |
| 13 | +Filename: pool/d4e0296c516812e2038ff3574f99af7c1a4810612598c3360cb99de61e047011/vim_2%3a9.1.0496-1+b1_amd64.deb |
| 14 | +Size: 1619492 |
| 15 | +MD5sum: 65a0123a1fc76cf7695d90030f5e80d2 |
| 16 | +SHA1: b0aebce641b3c708235d940f50b1627b5fd42f99 |
| 17 | +SHA256: d4e0296c516812e2038ff3574f99af7c1a4810612598c3360cb99de61e047011 |
| 18 | +Section: editors |
| 19 | +Priority: optional |
| 20 | +Homepage: https://www.vim.org/ |
| 21 | +Description: Vi IMproved - enhanced vi editor |
| 22 | + This is a sample description. |
| 23 | + . |
| 24 | + It can have multiple lines. |
| 25 | + . |
| 26 | +
|
| 27 | +Package: vim-common |
| 28 | +Source: vim |
| 29 | +Version: 2:9.1.0496-1 |
| 30 | +Architecture: all |
| 31 | +Maintainer: Debian Vim Maintainers <[email protected]> |
| 32 | +Installed-Size: 1850 |
| 33 | +Recommends: xxd, vim | vim-gtk3 | vim-motif | vim-nox | vim-tiny |
| 34 | +Breaks: vim-runtime (<< 2:9.0.1658-1~) |
| 35 | +Replaces: vim-runtime (<< 2:9.0.1658-1~) |
| 36 | +Filename: pool/3eb851c9789f075d9e1dbdd721d40e5c6d0e835776518f66fd4335e0bb6f1f61/vim-common_2%3a9.1.0496-1_all.deb |
| 37 | +Size: 411852 |
| 38 | +MD5sum: 259c2baa838b5325829c88dbf583bf2b |
| 39 | +SHA1: 2b7252742fb40dff8ce3abbc6c54730a3e519b2f |
| 40 | +SHA256: 3eb851c9789f075d9e1dbdd721d40e5c6d0e835776518f66fd4335e0bb6f1f61 |
| 41 | +Section: editors |
| 42 | +Priority: important |
| 43 | +Multi-Arch: foreign |
| 44 | +Homepage: https://www.vim.org/ |
| 45 | +Description: Vi IMproved - Common files |
| 46 | +
|
| 47 | +Package: vim-runtime |
| 48 | +Source: vim |
| 49 | +Version: 2:9.1.0496-1 |
| 50 | +Architecture: all |
| 51 | +Maintainer: Debian Vim Maintainers <[email protected]> |
| 52 | +Installed-Size: 36945 |
| 53 | +Recommends: vim | vim-gtk3 | vim-motif | vim-nox | vim-tiny |
| 54 | +Enhances: vim-tiny |
| 55 | +Breaks: vim-tiny (<< 2:9.1.0496-1) |
| 56 | +Filename: pool/488a128a939e430f681230ef9fd83b371585f0e0d3cf7649f135270133b5b162/vim-runtime_2%3a9.1.0496-1_all.deb |
| 57 | +Size: 7116680 |
| 58 | +MD5sum: a2e9e7a7907644444b7555eb6b23ce59 |
| 59 | +SHA1: 330bb657c0249504a3114f56cd70848bee5e7270 |
| 60 | +SHA256: 488a128a939e430f681230ef9fd83b371585f0e0d3cf7649f135270133b5b162 |
| 61 | +Section: editors |
| 62 | +Priority: optional |
| 63 | +Multi-Arch: foreign |
| 64 | +Homepage: https://www.vim.org/ |
| 65 | +Description: Vi IMproved - Runtime files |
| 66 | +
|
| 67 | +Package: vim-tiny |
| 68 | +Source: vim (2:9.1.0496-1) |
| 69 | +Version: 2:9.1.0496-1+b1 |
| 70 | +Architecture: amd64 |
| 71 | +Maintainer: Debian Vim Maintainers <[email protected]> |
| 72 | +Installed-Size: 1750 |
| 73 | +Depends: vim-common (= 2:9.1.0496-1), libacl1 (>= 2.2.23), libc6 (>= 2.34), libselinux1 (>= 3.1~), libtinfo6 (>= 6) |
| 74 | +Suggests: indent |
| 75 | +Provides: editor |
| 76 | +Filename: pool/a44d841ab0ba4dcea6da764126fbfa351642a913920ad15a10781239e4297e27/vim-tiny_2%3a9.1.0496-1+b1_amd64.deb |
| 77 | +Size: 743340 |
| 78 | +MD5sum: 518f5bb267de52be4613a9eaac5325fb |
| 79 | +SHA1: 5bc3956b165fd36a7da185ed3962afc7d0957d53 |
| 80 | +SHA256: a44d841ab0ba4dcea6da764126fbfa351642a913920ad15a10781239e4297e27 |
| 81 | +Section: editors |
| 82 | +Priority: important |
| 83 | +Homepage: https://www.vim.org/ |
| 84 | +Description: Vi IMproved - enhanced vi editor - compact version |
| 85 | +""" |
| 86 | + |
| 87 | + |
| 88 | +def test_parse_debsource_file(): |
| 89 | + expected = sorted( |
| 90 | + [ |
| 91 | + "vim-common 2:9.1.0496-1", |
| 92 | + "vim-runtime 2:9.1.0496-1", |
| 93 | + "vim-tiny 2:9.1.0496-1+b1", |
| 94 | + "vim 2:9.1.0496-1+b1", |
| 95 | + ] |
| 96 | + ) |
| 97 | + unit_under_test = DebsrcFile() |
| 98 | + |
| 99 | + unit_under_test.read(io.StringIO(test_data)) |
| 100 | + |
| 101 | + # Explicitly sort list for comparison because the order is not deterministic |
| 102 | + actual = sorted([f"{f'{package!r}'}" for package in unit_under_test.values()]) |
| 103 | + assert expected == actual |
0 commit comments