Add simple regression testing code and tests for some issues.
[oweals/opkg-lede.git] / tests / regress / issue50.py
1 #!/usr/bin/python3
2
3 import os
4 import opk, cfg, opkgcl
5
6 opk.regress_init()
7
8 open("foo", "w").close()
9 a1 = opk.Opk(Package="a", Version="1.0", Architecture="all")
10 a1.write(data_files=["foo"])
11
12 exit()
13 opkgcl.install("a_1.0_all.opk")
14
15 o = opk.OpkGroup()
16 a2 = opk.Opk(Package="a", Version="2.0", Architecture="all", Depends="b")
17 a2.write()
18 b1 = opk.Opk(Package="b", Version="1.0", Architecture="all")
19 b1.write(data_files=["foo"])
20 o.opk_list.append(a2)
21 o.opk_list.append(b1)
22 o.write_list()
23
24 os.unlink("foo")
25
26 opkgcl.update()
27 opkgcl.upgrade()
28
29 if not opkgcl.is_installed("a", "2.0"):
30         print(__file__, ": Package 'a_2.0' not installed.")
31         exit(False)
32
33 foo_fullpath = "{}/foo".format(cfg.offline_root)
34
35 if not os.path.exists(foo_fullpath):
36         print(__file__, ": File 'foo' incorrectly orphaned.")
37         exit(False)
38
39 if not foo_fullpath in opkgcl.files("b"):
40         print(__file__, ": Package 'b' does not own file 'foo'.")
41         exit(False)
42
43 opkgcl.remove("a")
44 opkgcl.remove("b")