0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
import unittest
|
|
18 |
import string
|
|
19 |
import sys,os
|
|
20 |
import pickle
|
|
21 |
|
|
22 |
from cone.public import api
|
|
23 |
from cone.storage import stringstorage
|
|
24 |
|
|
25 |
class TestStringStorage(unittest.TestCase):
|
|
26 |
def test_internal_add_and_list(self):
|
|
27 |
store = api.Storage.open("test.pk","w")
|
|
28 |
store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test1.txt"))
|
|
29 |
store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test2.txt"))
|
|
30 |
self.assertEquals(store._get("test.foo.bar")._list(),
|
|
31 |
['test1',
|
|
32 |
'test2'])
|
|
33 |
store.close()
|
|
34 |
os.unlink("test.pk")
|
|
35 |
|
|
36 |
def test_internal_add_get_and_list(self):
|
|
37 |
store = api.Storage.open("test.pk","w")
|
|
38 |
obj = stringstorage._StringStorageObject("test1.txt")
|
|
39 |
store._add_to_path("test.foo.bar",obj)
|
|
40 |
store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test2.txt"))
|
|
41 |
obj.data = "Fooo"
|
|
42 |
self.assertEquals(store._get("test.foo.bar")._list(),
|
|
43 |
['test1',
|
|
44 |
'test2'])
|
|
45 |
self.assertEquals(store.test.foo.bar.test1.data,'Fooo')
|
|
46 |
store.close()
|
|
47 |
os.unlink("test.pk")
|
|
48 |
|
|
49 |
def test_internal_add_get_and_list_all(self):
|
|
50 |
store = api.Storage.open("test.pk","w")
|
|
51 |
store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test1.txt"))
|
|
52 |
store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test2.txt"))
|
|
53 |
store._add(stringstorage._StringStorageObject("root.txt"))
|
|
54 |
self.assertEquals(store._list_traverse(type=stringstorage._StringStorageObject), ['test.foo.bar.test1',
|
|
55 |
'test.foo.bar.test2',
|
|
56 |
'root'])
|
|
57 |
store.close()
|
|
58 |
os.unlink("test.pk")
|
|
59 |
|