Skip to content

Commit 469bd5c

Browse files
committed
more tests
1 parent f45aeab commit 469bd5c

File tree

4 files changed

+78
-5
lines changed

4 files changed

+78
-5
lines changed

src/DataBlobs/entities/AbstractDataEntries.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ _uniqueKey(dfg::AbstractDFG, v::AbstractDFGVariable, key::Symbol)::Symbol =
5252

5353
GeneralDataEntry(key::Symbol, storeKey::Symbol; mimeType::String="") = error("storeKey Deprecated, use UUID")
5454

55-
GeneralDataEntry(label::Symbol, id::UUID;
55+
GeneralDataEntry(label::Symbol, id::UUID=uuid4();
5656
mimeType::String="application/octet-stream") =
57-
GeneralDataEntry(label, uuid4(), now(localzone()), now(localzone()), mimeType)
57+
GeneralDataEntry(label, id, now(localzone()), now(localzone()), mimeType)
5858

5959
function GeneralDataEntry(dfg::AbstractDFG, var::AbstractDFGVariable, key::Symbol;
6060
mimeType::String="application/octet-stream")

test/fileDFGTests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ using Test
2727

2828
setSolvedCount!(verts[1], 5)
2929
# Add some data entries to x1, x2
30-
addDataEntry!(verts[1], GeneralDataEntry(:testing, :testing; mimeType="application/nuthin!"))
31-
addDataEntry!(verts[2], FileDataEntry(:testing2, "/dev/null"))
30+
addDataEntry!(verts[1], GeneralDataEntry(:testing; mimeType="application/nuthin!"))
31+
addDataEntry!(verts[2], GeneralDataEntry(:testing2))
3232
#call update to set it on cloud
3333
updateVariable!(dfg, verts[1])
3434
updateVariable!(dfg, verts[2])
@@ -64,6 +64,6 @@ using Test
6464
@test length(getDataEntries(getVariable(retDFG, :x1))) == 1
6565
@test typeof(getDataEntry(getVariable(retDFG, :x1),:testing)) == GeneralDataEntry
6666
@test length(getDataEntries(getVariable(retDFG, :x2))) == 1
67-
@test typeof(getDataEntry(getVariable(retDFG, :x2),:testing2)) == FileDataEntry
67+
@test typeof(getDataEntry(getVariable(retDFG, :x2),:testing2)) == GeneralDataEntry
6868
end
6969
end

test/interfaceTests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ end
207207
@test getFactor(dfg, fac.label) == getFactor(copyDfg, fac.label)
208208
# @test getFactor(dfg, fac.label) == fac
209209
end
210+
211+
FileDFGTestBlock(testDFGAPI)
210212
end
211213
#=
212214
fg = fg1

test/testBlocks.jl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function Base.convert(::Type{DFG.FunctionNodeData{TestCCW{F}}},
7676
TestCCW(convert(F, d.fnc)),
7777
d.multihypo,
7878
d.certainhypo,
79+
d.nullhypo,
7980
d.solveInProgress)
8081
end
8182

@@ -87,6 +88,7 @@ function Base.convert(::Type{DFG.PackedFunctionNodeData{P}}, d::DFG.FunctionNode
8788
convert(P, d.fnc.usrfnc!),
8889
d.multihypo,
8990
d.certainhypo,
91+
d.nullhypo,
9092
d.solveInProgress)
9193
end
9294

@@ -1370,3 +1372,72 @@ function CopyFunctionsTest(testDFGAPI; kwargs...)
13701372
# GraphsDFG(dfg)
13711373

13721374
end
1375+
1376+
function FileDFGTestBlock(testDFGAPI; kwargs...)
1377+
1378+
# testDFGAPI = LightDFG
1379+
# kwargs = ()
1380+
# filename = "/tmp/fileDFG"
1381+
dfg, verts, facs = connectivityTestGraph(testDFGAPI; kwargs...)
1382+
1383+
for filename in ["/tmp/fileDFG", "/tmp/FileDFGExtension.tar.gz"]
1384+
1385+
v4 = getVariable(dfg, :x4)
1386+
vnd = getSolverData(v4)
1387+
# set everything
1388+
vnd.BayesNetVertID = :outid
1389+
push!(vnd.BayesNetOutVertIDs, :id)
1390+
vnd.bw[1] = 1.0
1391+
push!(vnd.dimIDs, 1)
1392+
vnd.dims = 1
1393+
vnd.dontmargin = true
1394+
vnd.eliminated = true
1395+
vnd.inferdim = 1.5
1396+
vnd.initialized = true
1397+
vnd.ismargin = true
1398+
push!(vnd.separator, :sep)
1399+
vnd.solveInProgress = 1
1400+
vnd.solvedCount = 2
1401+
vnd.val .= 2.0
1402+
#update
1403+
updateVariable!(dfg, v4)
1404+
1405+
f45 = getFactor(dfg, :x4x5f1)
1406+
fsd = f45.solverData
1407+
# set some factor solver data
1408+
push!(fsd.certainhypo, 2)
1409+
push!(fsd.edgeIDs, 3)
1410+
fsd.eliminated = true
1411+
push!(fsd.multihypo, 4.0)
1412+
fsd.nullhypo = 5.0
1413+
fsd.potentialused = true
1414+
fsd.solveInProgress = true
1415+
#update factor
1416+
updateFactor!(dfg, f45)
1417+
1418+
# Save and load the graph to test.
1419+
saveDFG(dfg, filename)
1420+
1421+
retDFG = testDFGAPI()
1422+
@info "Going to load $filename"
1423+
1424+
@test_throws AssertionError loadDFG!(retDFG,"badfilename")
1425+
1426+
loadDFG!(retDFG, filename)
1427+
1428+
@test issetequal(ls(dfg), ls(retDFG))
1429+
@test issetequal(lsf(dfg), lsf(retDFG))
1430+
for var in ls(dfg)
1431+
@test getVariable(dfg, var) == getVariable(retDFG, var)
1432+
end
1433+
for fact in lsf(dfg)
1434+
@test getFactor(dfg, fact) == getFactor(retDFG, fact)
1435+
end
1436+
1437+
# @test length(getDataEntries(getVariable(retDFG, :x1))) == 1
1438+
# @test typeof(getDataEntry(getVariable(retDFG, :x1),:testing)) == GeneralDataEntry
1439+
# @test length(getDataEntries(getVariable(retDFG, :x2))) == 1
1440+
# @test typeof(getDataEntry(getVariable(retDFG, :x2),:testing2)) == FileDataEntry
1441+
end
1442+
1443+
end

0 commit comments

Comments
 (0)