OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-storage commits / 4d6da0d

Convert more unit tests away from deprecaed API
4d6da0d4338052d73fc324a58a0af93f14c15977
by Linas Vepstas <linasvepstas@gmail.com> · 2026-01-18T03:39:57.000Z

Changed files (4) +49 -49

tests/persist/flow/fetch-value-of-test.scm +2 -2
……@@ -14,7 +14,7 @@
1414; but, for convenience, we just use Postgres for now.
1515(define sto (PostgresStorageNode
1616 "postgres:///opencog_test?user=opencog_tester&password=cheese"))
17(cog-open sto)
17(cog-set-value! sto (*-open-*))
1818(cog-erase! sto)
1919
2020(define fvof (FetchValueOf (Concept "a") (Predicate "foo") sto))
……@@ -36,7 +36,7 @@
3636(test-assert "Reset" (equal? fv (cog-execute! fvof)))
3737
3838(cog-erase! sto)
39(cog-close sto)
39(cog-set-value! sto (*-close-*))
4040(test-end tname)
4141
4242(opencog-test-end)
tests/persist/proxy/proxy-node-test.scm +24 -24
……@@ -41,12 +41,12 @@
4141(define wnull (WriteThruProxy "wnull"))
4242(cog-set-value! wnull parts (NullProxy "bar"))
4343
44(cog-open wnull)
45(store-atom (Concept "boffo"))
46(cog-close wnull)
44(cog-set-value! wnull (*-open-*))
45(cog-set-value! wnull (*-store-atom-*) (Concept "boffo"))
46(cog-set-value! wnull (*-close-*))
4747
4848(set! caught #f)
49(catch 'C++-EXCEPTION (lambda () (store-atom (Concept "boffo")))
49(catch 'C++-EXCEPTION (lambda () (cog-set-value! wnull (*-store-atom-*) (Concept "boffo")))
5050 (lambda (key funcname msg)
5151 (format #t "Yes, we got the exception as expected\n")
5252 (set! caught #t)))
……@@ -63,12 +63,12 @@
6363 (NullProxy "bar")
6464 (NullProxy "baz")))
6565
66(cog-open wmulti)
67(store-atom (Concept "boffo"))
68(cog-close wmulti)
66(cog-set-value! wmulti (*-open-*))
67(cog-set-value! wmulti (*-store-atom-*) (Concept "boffo"))
68(cog-set-value! wmulti (*-close-*))
6969
7070(set! caught #f)
71(catch 'C++-EXCEPTION (lambda () (store-atom (Concept "boffo")))
71(catch 'C++-EXCEPTION (lambda () (cog-set-value! wmulti (*-store-atom-*) (Concept "boffo")))
7272 (lambda (key funcname msg)
7373 (format #t "Yes, we got the exception as expected\n")
7474 (set! caught #t)))
……@@ -82,15 +82,15 @@
8282(define rnull (ReadThruProxy "wnull"))
8383(cog-set-value! rnull parts (NullProxy "bar"))
8484
85(cog-open rnull)
86(fetch-atom (Concept "b1"))
87(fetch-atom (Concept "b2"))
88(fetch-atom (Concept "b3"))
89(fetch-atom (Concept "b4"))
90(cog-close rnull)
85(cog-set-value! rnull (*-open-*))
86(cog-set-value! rnull (*-fetch-atom-*) (Concept "b1"))
87(cog-set-value! rnull (*-fetch-atom-*) (Concept "b2"))
88(cog-set-value! rnull (*-fetch-atom-*) (Concept "b3"))
89(cog-set-value! rnull (*-fetch-atom-*) (Concept "b4"))
90(cog-set-value! rnull (*-close-*))
9191
9292(set! caught #f)
93(catch 'C++-EXCEPTION (lambda () (fetch-atom (Concept "boffo")))
93(catch 'C++-EXCEPTION (lambda () (cog-set-value! rnull (*-fetch-atom-*) (Concept "boffo")))
9494 (lambda (key funcname msg)
9595 (format #t "Yes, we got the exception as expected\n")
9696 (set! caught #t)))
……@@ -107,17 +107,17 @@
107107 (NullProxy "bar")
108108 (NullProxy "baz")))
109109
110(cog-open rmulti)
111(fetch-atom (Concept "b1"))
112(fetch-atom (Concept "b2"))
113(fetch-atom (Concept "b3"))
114(fetch-atom (Concept "b4"))
115(fetch-atom (Concept "b5"))
116(fetch-atom (Concept "b6"))
117(cog-close rmulti)
110(cog-set-value! rmulti (*-open-*))
111(cog-set-value! rmulti (*-fetch-atom-*) (Concept "b1"))
112(cog-set-value! rmulti (*-fetch-atom-*) (Concept "b2"))
113(cog-set-value! rmulti (*-fetch-atom-*) (Concept "b3"))
114(cog-set-value! rmulti (*-fetch-atom-*) (Concept "b4"))
115(cog-set-value! rmulti (*-fetch-atom-*) (Concept "b5"))
116(cog-set-value! rmulti (*-fetch-atom-*) (Concept "b6"))
117(cog-set-value! rmulti (*-close-*))
118118
119119(set! caught #f)
120(catch 'C++-EXCEPTION (lambda () (fetch-atom (Concept "boffo")))
120(catch 'C++-EXCEPTION (lambda () (cog-set-value! rmulti (*-fetch-atom-*) (Concept "boffo")))
121121 (lambda (key funcname msg)
122122 (format #t "Yes, we got the exception as expected\n")
123123 (set! caught #t)))
tests/persist/proxy/read-proxy-test.scm +12 -12
……@@ -20,20 +20,20 @@
2020(define wsto (WriteThruProxy "writer"))
2121(cog-set-value! wsto (Predicate "*-proxy-parts-*") sto)
2222
23(cog-open wsto)
23(cog-set-value! wsto (*-open-*))
2424(define b1 (Concept "b1"))
2525(cog-set-value! b1 (Predicate "*-TruthValueKey-*") (FloatValue 0.1 0.1))
26(store-atom b1)
26(cog-set-value! wsto (*-store-atom-*) b1)
2727(define b2 (Concept "b2"))
2828(cog-set-value! b2 (Predicate "*-TruthValueKey-*") (FloatValue 0.2 0.2))
29(store-atom b2)
29(cog-set-value! wsto (*-store-atom-*) b2)
3030(define b3 (Concept "b3"))
3131(cog-set-value! b3 (Predicate "*-TruthValueKey-*") (FloatValue 0.3 0.3))
32(store-atom b3)
32(cog-set-value! wsto (*-store-atom-*) b3)
3333(define b4 (Concept "b4"))
3434(cog-set-value! b4 (Predicate "*-TruthValueKey-*") (FloatValue 0.4 0.4))
35(store-atom b4)
36(cog-close wsto)
35(cog-set-value! wsto (*-store-atom-*) b4)
36(cog-set-value! wsto (*-close-*))
3737
3838; ----------------------------
3939; Now, read it back.
……@@ -46,12 +46,12 @@
4646(define rsto (ReadThruProxy "reader"))
4747(cog-set-value! rsto (Predicate "*-proxy-parts-*") sto)
4848
49(cog-open rsto)
50(fetch-atom (Concept "b1"))
51(fetch-atom (Concept "b2"))
52(fetch-atom (Concept "b3"))
53(fetch-atom (Concept "b4"))
54(cog-close rsto)
49(cog-set-value! rsto (*-open-*))
50(cog-set-value! rsto (*-fetch-atom-*) (Concept "b1"))
51(cog-set-value! rsto (*-fetch-atom-*) (Concept "b2"))
52(cog-set-value! rsto (*-fetch-atom-*) (Concept "b3"))
53(cog-set-value! rsto (*-fetch-atom-*) (Concept "b4"))
54(cog-set-value! rsto (*-close-*))
5555
5656(test-approximate "b1" 0.1 (cog-mean (Concept "b1")) 1.0e-8)
5757(test-approximate "b2" 0.2 (cog-mean (Concept "b2")) 1.0e-8)
tests/persist/sexpr/file-storage.scm +11 -11
……@@ -32,27 +32,27 @@
3232
3333; Store some individual Atoms, and then store everything.
3434(define wfsn (FileStorageNode fname))
35(cog-open wfsn)
35(cog-set-value! wfsn (*-open-*))
3636
3737; Store just one Atom.
38(store-atom wa wfsn)
38(cog-set-value! wfsn (*-store-atom-*) wa)
3939
4040; Store just one value on an Atom. Store it three times;
4141; it will show up in the file three times.
4242(cog-set-value! wa (Predicate "num") (FloatValue 11 22 33))
43(store-value wa (Predicate "num") wfsn)
44(store-value wa (Predicate "num") wfsn)
45(store-value wa (Predicate "num") wfsn)
43(cog-set-value! wfsn (*-store-value-*) wa (Predicate "num"))
44(cog-set-value! wfsn (*-store-value-*) wa (Predicate "num"))
45(cog-set-value! wfsn (*-store-value-*) wa (Predicate "num"))
4646
4747; The file write might not occur until after the `barrier` call.
4848; File writes are buffered by the operating system.
49(barrier wfsn)
49(cog-set-value! wfsn (*-barrier-*) (cog-atomspace))
5050
5151; Now store everything. This will appear after the writes above,
5252; and will duplicate some of the earlier data. During file read,
5353; later data in the file will take precedence over earlier data.
54(store-atomspace wfsn)
55(cog-close wfsn)
54(cog-set-value! wfsn (*-store-atomspace-*) (cog-atomspace))
55(cog-set-value! wfsn (*-close-*))
5656
5757(cog-atomspace-clear)
5858
……@@ -60,9 +60,9 @@
6060
6161; Load everything from the file.
6262(define rfsn (FileStorageNode fname))
63(cog-open rfsn)
64(load-atomspace rfsn)
65(cog-close rfsn)
63(cog-set-value! rfsn (*-open-*))
64(cog-set-value! rfsn (*-load-atomspace-*) (cog-atomspace))
65(cog-set-value! rfsn (*-close-*))
6666
6767; Verify the load
6868(cog-prt-atomspace)