Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify SD_WS07 Autocreate via unittest #536

Merged
merged 4 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ test: deploylocal
test/test-runner.sh test_sub_SIGNALduino_OSV2
test/test-runner.sh test_sub_MCTFA
test/test-runner.sh test_sub_SIGNALduino_getAttrDevelopment
test/test-runner.sh test_SDWS07
@echo === finished unit tests ===
sudo timeout 30 killall -vw perl || sudo killall -vws9 perl
67 changes: 67 additions & 0 deletions test/test_SDWS07-definition.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
defmod test_SDWS07 UnitTest dummyDuino (
{
CommandAttr(undef,"autocreate verbose 5");

my $sensorname="SD_WS07_TH_1";
subtest "Check autocreate $sensorname" => sub {
plan tests => 3;
Dispatch($targetHash,"P7#6300C6F0B");
ok(!IsDevice($sensorname), "check sensor not created with single dispatch");
sleep 3;
Dispatch($targetHash,"P7#6300C6F0B");
ok(IsDevice($sensorname), "check sensor created with second dispatch");
CommandDelete(undef,$sensorname);
ok(!IsDevice($sensorname), "check sensor deleted correctly");
};

sleep 3;
subtest "Check Dispatch() with existing definition only channel $sensorname" => sub {
plan tests => 4 ;
ok(!IsDevice($sensorname), "check sensor deleted correctly");
CommandDefine(undef,"$sensorname SD_WS07 1");
ok(IsDevice($sensorname), "check sensor not created with single dispatch");
my $found=Dispatch($targetHash,"P7#6300C6F0B");
is($found->[0],$sensorname,"Check if definition is found by dispatch()");
CommandDelete(undef,$sensorname);
ok(!IsDevice($sensorname), "check sensor deleted correctly");

};

sleep 3;
subtest "Check Dispatch() with existing definition model_channel $sensorname" => sub {
plan tests => 4;
ok(!IsDevice($sensorname), "check sensor deleted correctly");

CommandDefine(undef,"$sensorname SD_WS07 SD_WS07_TH_1");
ok(IsDevice($sensorname), "check sensor not created with single dispatch");
my $found=Dispatch($targetHash,"P7#6300C6F0B");
TODO: {
local $TODO="This bug must be fixed";
is($found->[0],$sensorname,"Check if definition is found by dispatch()") || diag(explain $found);
};
CommandDelete(undef,$sensorname);
ok(!IsDevice($sensorname), "check sensor deleted correctly");
};


$sensorname="SD_WS07_TH_631";
sleep 3;
subtest "Check autocreate with longid $sensorname" => sub {
CommandAttr(undef,"$target longids 1");
plan tests => 4;

Dispatch($targetHash,"P7#6300C6F0B");
ok(!IsDevice($sensorname), "check sensor not created with single dispatch");
sleep 4;
Dispatch($targetHash,"P7#6300C6F0B");
ok(IsDevice($sensorname), "check sensor created with second dispatch");
sleep 1;
my $found=Dispatch($targetHash,"P7#6300C6F0B");
is($found->[0],$sensorname,"Check if definition is found by dispatch()") || diag(explain $found);
CommandDelete(undef,$sensorname);
ok(!IsDevice($sensorname), "check sensor deleted correctly");
CommandDeleteAttr(undef,"$target longids");
};

}
)