-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,72 @@ | ||
@testset "Test add_info" begin | ||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
IS.add_info!(container, geo_info) | ||
component = IS.TestComponent("component1", 5) | ||
IS.add_info!(container, geo_info, component) | ||
@test length(container.data) == 1 | ||
@test length(container.data[IS.InfrastructureSystemsGeo]) == 1 | ||
@test IS.get_num_infos(container) == 1 | ||
@test_throws ArgumentError IS.add_info!(container, geo_info, component) | ||
|
||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
@test_throws ArgumentError IS._add_info!(container, geo_info) | ||
end | ||
|
||
@testset "Test clear_infos" begin | ||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
component = IS.TestComponent("component1", 5) | ||
IS.add_info!(container, geo_info, component) | ||
@test IS.get_num_infos(container) == 1 | ||
|
||
IS.clear_infos!(component) | ||
@test isempty(IS.get_components_uuid(geo_info)) | ||
IS.clear_infos!(container) | ||
infos = IS.get_infos(IS.InfrastructureSystemsGeo, container) | ||
@test length(infos) == 0 | ||
end | ||
|
||
@testset "Test remove_info" begin | ||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
component = IS.TestComponent("component1", 5) | ||
IS.add_info!(container, geo_info, component) | ||
@test IS.get_num_infos(container) == 1 | ||
|
||
@test_throws ArgumentError IS.add_component!(container, component) | ||
IS.remove_info!(component, geo_info) | ||
@test isempty(IS.get_infos_container(component)) | ||
@test isempty(IS.get_components_uuid(geo_info)) | ||
end | ||
|
||
struct BadComponent | ||
name::AbstractString | ||
val::Int | ||
@testset "Test iterate_Infos" begin | ||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
component = IS.TestComponent("component1", 5) | ||
IS.add_info!(container, geo_info, component) | ||
|
||
i = 0 | ||
for component in IS.iterate_infos(container) | ||
i += 1 | ||
end | ||
@test i == 1 | ||
end | ||
|
||
container = IS.Components(IS.InMemoryTimeSeriesStorage()) | ||
component = BadComponent("component1", 5) | ||
@test_throws MethodError IS.add_component!(container, component) | ||
@testset "Summarize Infos" begin | ||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
component = IS.TestComponent("component1", 5) | ||
IS.add_info!(container, geo_info, component) | ||
summary(devnull, container) | ||
end | ||
|
||
@testset "Test infos serialization" begin | ||
container = IS.Infos(IS.InMemoryTimeSeriesStorage()) | ||
geo_info = IS.InfrastructureSystemsGeo() | ||
component = IS.TestComponent("component1", 5) | ||
IS.add_info!(container, geo_info, component) | ||
data = IS.serialize(container) | ||
@test data isa Vector | ||
@test !isempty(data) | ||
@test data[1] isa Dict | ||
end |