Refine TestJsonReadNotecard() and use / instead of . to separate paths.

An attack of the stupid meant that I was using / as a path separator.
Fixing this makes the tests behave better, though still with some questions.
Also, I imagine / shouldn't really put data in the root as that's not a valid identifier.
This commit also fix the / mistake in other tests those this does not affect their outcomes.
0.7.4-extended
Justin Clark-Casey (justincc) 2013-02-08 01:59:27 +00:00
parent 3f6feec914
commit 90d71d423c
1 changed files with 46 additions and 15 deletions

View File

@ -283,7 +283,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
string notecardName = "nc1"; string notecardName = "nc1";
// Write notecard // Write notecard
UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "", notecardName);
Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName); TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName);
@ -292,8 +292,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
// TODO: Should independently check the contents. // TODO: Should independently check the contents.
} }
// TODO: Write partial test
{ {
// Try to write notecard against bad path // Try to write notecard for a bad path
// In this case we do get a request id but no notecard is written. // In this case we do get a request id but no notecard is written.
string badPathNotecardName = "badPathNotecardName"; string badPathNotecardName = "badPathNotecardName";
@ -312,7 +314,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
UUID fakeStoreId = TestHelpers.ParseTail(0x500); UUID fakeStoreId = TestHelpers.ParseTail(0x500);
UUID fakeStoreWriteNotecardValue UUID fakeStoreWriteNotecardValue
= (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, fakeStoreId, "/", fakeStoreNotecardName); = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, fakeStoreId, "", fakeStoreNotecardName);
Assert.That(fakeStoreWriteNotecardValue, Is.Not.EqualTo(UUID.Zero)); Assert.That(fakeStoreWriteNotecardValue, Is.Not.EqualTo(UUID.Zero));
TaskInventoryItem fakeStoreItem = so.RootPart.Inventory.GetInventoryItem(fakeStoreNotecardName); TaskInventoryItem fakeStoreItem = so.RootPart.Inventory.GetInventoryItem(fakeStoreNotecardName);
@ -341,12 +343,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
UUID creatingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); UUID creatingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
// Write notecard // Write notecard
InvokeOpOnHost("JsonWriteNotecard", so.UUID, creatingStoreId, "/", notecardName); InvokeOpOnHost("JsonWriteNotecard", so.UUID, creatingStoreId, "", notecardName);
{ {
// Read notecard // Read notecard
UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}"); UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}");
UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName); UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "", notecardName);
Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello"); string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello");
@ -354,23 +356,52 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
} }
{ {
// Read notecard to non-root path // Read notecard to new single component path
UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}"); UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}");
UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make/it/so", notecardName); UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make", notecardName);
Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
// These don't behave as I expect yet - reading to a path still seems to place the notecard contents at the root. // These don't behave as I expect yet - reading to a path still seems to place the notecard contents at the root.
// string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello"); string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello");
// Assert.That(value, Is.EqualTo("")); Assert.That(value, Is.EqualTo(""));
//
// value = (string)InvokeOp("JsonGetValue", receivingStoreId, "make/it/so/Hello"); value = (string)InvokeOp("JsonGetValue", receivingStoreId, "make.Hello");
// Assert.That(value, Is.EqualTo("World")); Assert.That(value, Is.EqualTo("World"));
}
{
// Read notecard to new multi-component path
UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}");
UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make.it", notecardName);
Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
// These don't behave as I expect yet - reading to a path still seems to place the notecard contents at the root.
string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello");
Assert.That(value, Is.EqualTo(""));
// TODO: Check that we are not expecting reading to a new path to work.
value = (string)InvokeOp("JsonGetValue", receivingStoreId, "make.it.Hello");
Assert.That(value, Is.EqualTo(""));
}
{
// Read notecard to existing multi-component path
UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'make' : { 'it' : 'so' } }");
UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make.it", notecardName);
Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
// These don't behave as I expect yet - reading to a path still seems to place the notecard contents at the root.
string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello");
Assert.That(value, Is.EqualTo(""));
value = (string)InvokeOp("JsonGetValue", receivingStoreId, "make.it.Hello");
Assert.That(value, Is.EqualTo("World"));
} }
{ {
// Try read notecard to fake store. // Try read notecard to fake store.
UUID fakeStoreId = TestHelpers.ParseTail(0x500); UUID fakeStoreId = TestHelpers.ParseTail(0x500);
UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, fakeStoreId, "/", notecardName); UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, fakeStoreId, "", notecardName);
Assert.That(fakeStoreId, Is.Not.EqualTo(UUID.Zero)); Assert.That(fakeStoreId, Is.Not.EqualTo(UUID.Zero));
string value = (string)InvokeOp("JsonGetValue", fakeStoreId, "Hello"); string value = (string)InvokeOp("JsonGetValue", fakeStoreId, "Hello");