configurationengine/source/cone/storage/tests/unittest_stringstorage.py
changeset 0 2e8eeb919028
child 3 e7e0ae78773e
equal deleted inserted replaced
-1:000000000000 0:2e8eeb919028
       
     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 import __init__
       
    22 
       
    23 from cone.public import api
       
    24 from cone.storage import stringstorage
       
    25 
       
    26 class TestStringStorage(unittest.TestCase):
       
    27     def test_internal_add_and_list(self):
       
    28         store = api.Storage.open("test.pk","w")
       
    29         store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test1.txt"))
       
    30         store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test2.txt"))
       
    31         self.assertEquals(store._get("test.foo.bar")._list(), 
       
    32                           ['test1',
       
    33                           'test2'])
       
    34         store.close()
       
    35         os.unlink("test.pk")
       
    36 
       
    37     def test_internal_add_get_and_list(self):
       
    38         store = api.Storage.open("test.pk","w")
       
    39         obj = stringstorage._StringStorageObject("test1.txt")
       
    40         store._add_to_path("test.foo.bar",obj)
       
    41         store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test2.txt"))
       
    42         obj.data = "Fooo"
       
    43         self.assertEquals(store._get("test.foo.bar")._list(), 
       
    44                           ['test1',
       
    45                           'test2'])
       
    46         self.assertEquals(store.test.foo.bar.test1.data,'Fooo')
       
    47         store.close()
       
    48         os.unlink("test.pk")
       
    49 
       
    50     def test_internal_add_get_and_list_all(self):
       
    51         store = api.Storage.open("test.pk","w")
       
    52         store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test1.txt"))
       
    53         store._add_to_path("test.foo.bar",stringstorage._StringStorageObject("test2.txt"))
       
    54         store._add(stringstorage._StringStorageObject("root.txt"))
       
    55         self.assertEquals(store._list_traverse(type=stringstorage._StringStorageObject), ['test.foo.bar.test1',
       
    56                                                       'test.foo.bar.test2',
       
    57                                                       'root'])
       
    58         store.close()
       
    59         os.unlink("test.pk")
       
    60