Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/units/volume.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/volume.py')
-rwxr-xr-xtests/units/volume.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/units/volume.py b/tests/units/volume.py
index aa01da0..2bceb99 100755
--- a/tests/units/volume.py
+++ b/tests/units/volume.py
@@ -2,11 +2,12 @@
# sugar-lint: disable
import json
+from os.path import exists
from __init__ import tests
import active_document as ad
-from sugar_network import node
+from sugar_network import node, sugar
from sugar_network.toolkit.collection import Sequence
from sugar_network.toolkit.sneakernet import InPacket, OutBufferPacket, DiskFull
from sugar_network.resources.volume import Volume, Resource, Commands, Request
@@ -334,6 +335,42 @@ class VolumeTest(tests.Test):
]),
sorted(call(cp, method='GET', document='context', reply=['guid', 'icon', 'layer'])['result']))
+ def test_Populate(self):
+ self.touch(
+ ('db/context/1/1/guid', '{"value": "1"}'),
+ ('db/context/1/1/ctime', '{"value": 1}'),
+ ('db/context/1/1/mtime', '{"value": 1}'),
+ ('db/context/1/1/seqno', '{"value": 0}'),
+ )
+
+ ds_path = sugar.profile_path('datastore')
+ self.touch(ds_path + '/index_updated')
+ self.touch((ds_path + '/2/2/metadata/uid', '2'))
+
+ volume = Volume('db', lazy_open=True)
+ cp = TestCommands(volume)
+
+ assert not exists('db/context/index')
+ assert not exists('db/artifact/index')
+
+ self.assertEqual(
+ [],
+ call(cp, method='GET', document='context')['result'])
+ coroutine.dispatch()
+ self.assertEqual(
+ [{'guid': '1'}],
+ call(cp, method='GET', document='context')['result'])
+ assert exists('db/context/index')
+
+ self.assertEqual(
+ [],
+ call(cp, method='GET', document='artifact')['result'])
+ coroutine.dispatch()
+ self.assertEqual(
+ [{'guid': '2'}],
+ call(cp, method='GET', document='artifact')['result'])
+ assert exists('db/artifact/index')
+
class TestCommands(ad.VolumeCommands, Commands):