Skip to content

Commit cd799c9

Browse files
committed
update tests from interfaceTests.jl
1 parent 936158e commit cd799c9

File tree

2 files changed

+88
-24
lines changed

2 files changed

+88
-24
lines changed

test/iifInterfaceTests.jl

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ end
149149
@test solverDataDict(v1) == v1.solverDataDict
150150
@test internalId(v1) == v1._internalId
151151

152+
@test softtype(v1) == :ContinuousScalar#Symbol(typeof(st1))
153+
@test softtype(v2) == :ContinuousScalar#Symbol(typeof(st2))
154+
@test typeof(getSofttype(v1)) == typeof(ContinuousScalar())
155+
152156
@test label(f1) == f1.label
153157
@test tags(f1) == f1.tags
154158
@test solverData(f1) == f1.data
@@ -167,6 +171,61 @@ end
167171

168172
@test !isInitialized(v2, key=:second)
169173

174+
# Session, robot, and user small data tests
175+
smallUserData = Dict{Symbol, String}(:a => "42", :b => "Hello")
176+
smallRobotData = Dict{Symbol, String}(:a => "43", :b => "Hello")
177+
smallSessionData = Dict{Symbol, String}(:a => "44", :b => "Hello")
178+
setUserData(dfg, deepcopy(smallUserData))
179+
setRobotData(dfg, deepcopy(smallRobotData))
180+
setSessionData(dfg, deepcopy(smallSessionData))
181+
@test getUserData(dfg) == smallUserData
182+
@test getRobotData(dfg) == smallRobotData
183+
@test getSessionData(dfg) == smallSessionData
184+
185+
end
186+
187+
@testset "BigData" begin
188+
oid = zeros(UInt8,12); oid[12] = 0x01
189+
de1 = MongodbBigDataEntry(:key1, NTuple{12,UInt8}(oid))
190+
191+
oid = zeros(UInt8,12); oid[12] = 0x02
192+
de2 = MongodbBigDataEntry(:key2, NTuple{12,UInt8}(oid))
193+
194+
oid = zeros(UInt8,12); oid[12] = 0x03
195+
de2_update = MongodbBigDataEntry(:key2, NTuple{12,UInt8}(oid))
196+
197+
#add
198+
v1 = getVariable(dfg, :a)
199+
@test addBigDataEntry!(v1, de1)
200+
@test addBigDataEntry!(dfg, :a, de2)
201+
@test addBigDataEntry!(v1, de1)
202+
203+
#get
204+
@test deepcopy(de1) == getBigDataEntry(v1, :key1)
205+
@test deepcopy(de2) == getBigDataEntry(dfg, :a, :key2)
206+
@test_throws Any getBigDataEntry(v2, :key1)
207+
@test_throws Any getBigDataEntry(dfg, :b, :key1)
208+
209+
#update
210+
@test updateBigDataEntry!(dfg, :a, de2_update)
211+
@test deepcopy(de2_update) == getBigDataEntry(dfg, :a, :key2)
212+
@test !updateBigDataEntry!(dfg, :b, de2_update)
213+
214+
#list
215+
entries = getBigDataEntries(dfg, :a)
216+
@test length(entries) == 2
217+
@test symdiff(map(e->e.key, entries), [:key1, :key2]) == Symbol[]
218+
@test length(getBigDataEntries(dfg, :b)) == 0
219+
220+
@test symdiff(getBigDataKeys(dfg, :a), [:key1, :key2]) == Symbol[]
221+
@test getBigDataKeys(dfg, :b) == Symbol[]
222+
223+
#delete
224+
@test deepcopy(de1) == deleteBigDataEntry!(v1, :key1)
225+
@test getBigDataKeys(v1) == Symbol[:key2]
226+
#delete from dfg
227+
@test deepcopy(de2_update) == deleteBigDataEntry!(dfg, :a, :key2)
228+
@test getBigDataKeys(v1) == Symbol[]
170229
end
171230

172231
@testset "Updating Nodes" begin
@@ -178,13 +237,13 @@ end
178237
estimates(newvar)[:default] = Dict{Symbol, VariableEstimate}(
179238
:max => VariableEstimate(:default, :max, [100.0]),
180239
:mean => VariableEstimate(:default, :mean, [50.0]),
181-
:ppe => VariableEstimate(:default, :ppe, [75.0]))
240+
:modefit => VariableEstimate(:default, :modefit, [75.0]))
182241
#update
183242
updateVariableSolverData!(dfg, newvar)
184243
#TODO maybe implement ==; @test newvar==var
185244
Base.:(==)(varest1::VariableEstimate, varest2::VariableEstimate) = begin
186245
varest1.lastUpdatedTimestamp == varest2.lastUpdatedTimestamp || return false
187-
varest1.type == varest2.type || return false
246+
varest1.ppeType == varest2.ppeType || return false
188247
varest1.solverKey == varest2.solverKey || return false
189248
varest1.estimate == varest2.estimate || return false
190249
return true
@@ -198,7 +257,7 @@ end
198257
estimates(newvar)[:second] = Dict{Symbol, VariableEstimate}(
199258
:max => VariableEstimate(:default, :max, [10.0]),
200259
:mean => VariableEstimate(:default, :mean, [5.0]),
201-
:ppe => VariableEstimate(:default, :ppe, [7.0]))
260+
:modefit => VariableEstimate(:default, :modefit, [7.0]))
202261

203262
# Persist to the original variable.
204263
updateVariableSolverData!(dfg, newvar)
@@ -348,9 +407,13 @@ end
348407
# Check all fields are equal for all variables
349408
for v in ls(summaryGraph)
350409
for field in variableFields
410+
if field != :softtypename
351411
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
412+
else
413+
@test softtype(getVariable(dfg, v)) == softtype(getVariable(summaryGraph, v))
352414
end
353415
end
416+
end
354417
for f in lsf(summaryGraph)
355418
for field in factorFields
356419
@test getfield(getFactor(dfg, f), field) == getfield(getFactor(summaryGraph, f), field)

test/runtests.jl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@ using Test
22
using GraphPlot # For plotting tests
33
using Neo4j
44
using DistributedFactorGraphs
5-
# using IncrementalInference
5+
using IncrementalInference
66

77
# Instantiate the APIs that you would like to test here
88
# Can do duplicates with different parameters.
9-
# apis = [
10-
# GraphsDFG{NoSolverParams}(),
11-
# LightDFG{NoSolverParams}(),
12-
# MetaGraphsDFG{NoSolverParams}(),
13-
# SymbolDFG{NoSolverParams}(),
14-
# CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test",
15-
# "testUser", "testRobot", "testSession",
16-
# nothing,
17-
# nothing,
18-
# IncrementalInference.decodePackedType,
19-
# IncrementalInference.rebuildFactorMetadata!,
20-
# solverParams=SolverParams())
21-
# ]
22-
# for api in apis
23-
# @testset "Testing Driver: $(typeof(api))" begin
24-
# @info "Testing Driver: $(api)"
25-
# global dfg = api
26-
# include("iifInterfaceTests.jl")
27-
# end
28-
# end
9+
apis = [
10+
GraphsDFG{NoSolverParams}(),
11+
LightDFG{NoSolverParams}(),
12+
DistributedFactorGraphs.MetaGraphsDFG{NoSolverParams}(),
13+
DistributedFactorGraphs.SymbolDFG{NoSolverParams}(),
14+
#skip cloud until Neo4j runs on travis
15+
# CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test",
16+
# "testUser", "testRobot", "testSession",
17+
# nothing,
18+
# nothing,
19+
# IncrementalInference.decodePackedType,
20+
# IncrementalInference.rebuildFactorMetadata!,
21+
# solverParams=SolverParams())
22+
]
23+
for api in apis
24+
@testset "Testing Driver: $(typeof(api))" begin
25+
@info "Testing Driver: $(api)"
26+
global dfg = api
27+
include("iifInterfaceTests.jl")
28+
end
29+
end
2930

3031
# Test each interface
3132
# Still test LightDFG and MetaGraphsDFG for the moment until we remove in 0.4.2

0 commit comments

Comments
 (0)