configurationengine/source/cone/storage/tests/unittest_webstorage_carbon.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 time
       
    22 import __init__
       
    23 
       
    24 from cone.public import api, exceptions
       
    25 from cone.storage import webstorage
       
    26 from cone.carbon import model, persistentjson
       
    27 import simplewebserver
       
    28 
       
    29 featurelist = {
       
    30     "featurelist": {
       
    31         "features": [
       
    32             {
       
    33                 "status": "APPROVED", 
       
    34                 "value_type": "", 
       
    35                 "description": "None", 
       
    36                 "title": "TestGroup", 
       
    37                 "ref": "testgroup", 
       
    38                 "type": "featuregroup", 
       
    39                 "id": 11749, 
       
    40                 "children": [
       
    41                     {
       
    42                         "status": "APPROVED", 
       
    43                         "value_type": "boolean", 
       
    44                         "description": "None", 
       
    45                         "title": "Child1", 
       
    46                         "ref": "child1", 
       
    47                         "type": "feature", 
       
    48                         "id": 11750, 
       
    49                         "children": []
       
    50                     }, 
       
    51                     {
       
    52                         "status": "APPROVED", 
       
    53                         "value_type": "boolean", 
       
    54                         "description": "None", 
       
    55                         "title": "Child1", 
       
    56                         "ref": "child1_1", 
       
    57                         "type": "feature", 
       
    58                         "id": 11751, 
       
    59                         "children": []
       
    60                     }, 
       
    61                     {
       
    62                         "status": "APPROVED", 
       
    63                         "value_type": "boolean", 
       
    64                         "description": "None", 
       
    65                         "title": "Child1", 
       
    66                         "ref": "child1_2", 
       
    67                         "type": "feature", 
       
    68                         "id": 11753, 
       
    69                         "children": []
       
    70                     }, 
       
    71                     {
       
    72                         "status": "APPROVED", 
       
    73                         "value_type": "boolean", 
       
    74                         "description": "Needs description", 
       
    75                         "title": "Child1", 
       
    76                         "ref": "child1_3", 
       
    77                         "type": "feature", 
       
    78                         "id": 11756, 
       
    79                         "children": []
       
    80                     }, 
       
    81                     {
       
    82                         "status": "APPROVED", 
       
    83                         "value_type": "boolean", 
       
    84                         "description": "Needs description", 
       
    85                         "title": "Child1", 
       
    86                         "ref": "child1_4", 
       
    87                         "type": "feature", 
       
    88                         "id": 11759, 
       
    89                         "children": []
       
    90                     }, 
       
    91                     {
       
    92                         "status": "APPROVED", 
       
    93                         "value_type": "boolean", 
       
    94                         "description": "None", 
       
    95                         "title": "Child2", 
       
    96                         "ref": "child2", 
       
    97                         "type": "feature", 
       
    98                         "id": 11754, 
       
    99                         "children": []
       
   100                     }, 
       
   101                     {
       
   102                         "status": "APPROVED", 
       
   103                         "value_type": "boolean", 
       
   104                         "description": "Needs description", 
       
   105                         "title": "Child2", 
       
   106                         "ref": "child2_1", 
       
   107                         "type": "feature", 
       
   108                         "id": 11757, 
       
   109                         "children": []
       
   110                     }, 
       
   111                     {
       
   112                         "status": "APPROVED", 
       
   113                         "value_type": "boolean", 
       
   114                         "description": "Needs description", 
       
   115                         "title": "Child2", 
       
   116                         "ref": "child2_2", 
       
   117                         "type": "feature", 
       
   118                         "id": 11760, 
       
   119                         "children": []
       
   120                     }
       
   121                 ]
       
   122             }, 
       
   123             {
       
   124                 "status": "APPROVED", 
       
   125                 "value_type": "", 
       
   126                 "description": "Needs description", 
       
   127                 "title": "TestGroup", 
       
   128                 "ref": "testgroup_3", 
       
   129                 "type": "featuregroup", 
       
   130                 "id": 11758, 
       
   131                 "children": []
       
   132             }, 
       
   133             {
       
   134                 "status": "APPROVED", 
       
   135                 "value_type": "", 
       
   136                 "description": "None", 
       
   137                 "title": "TestGroup", 
       
   138                 "ref": "testgroup_1", 
       
   139                 "type": "featuregroup", 
       
   140                 "id": 11752, 
       
   141                 "children": []
       
   142             }, 
       
   143             {
       
   144                 "status": "APPROVED", 
       
   145                 "value_type": "", 
       
   146                 "description": "Needs description", 
       
   147                 "title": "TestGroup", 
       
   148                 "ref": "testgroup_2", 
       
   149                 "type": "featuregroup", 
       
   150                 "id": 11755, 
       
   151                 "children": []
       
   152             }
       
   153         ], 
       
   154         "list_version_id": 34, 
       
   155         "expanded": True, 
       
   156         "version_identifier": "WORKING", 
       
   157         "is_latest_version": True, 
       
   158         "list_id": 37, 
       
   159         "path": "TEST4", 
       
   160         "version_title": "TEST4 (WORKING)", 
       
   161         "can_be_released": True, 
       
   162         "type": "featurelist", 
       
   163         "has_external_relations": False
       
   164     }
       
   165 }
       
   166 ROOT_PATH   = os.path.dirname(os.path.abspath(__file__))
       
   167 #class TestWebStorage(unittest.TestCase):
       
   168 #    def setUp(self):
       
   169 #        self.store = webstorage.WebStorage('http://localhost:8000/extapi')
       
   170 #        
       
   171 #    def test_create_and_list_resources(self):
       
   172 #        files = self.store.list_resources('/')
       
   173 #        print files
       
   174 #        self.assertTrue(len(files)>0)
       
   175 ##
       
   176 #    def test_create_and_list_resources_with_non_existing_folder(self):
       
   177 #        files = self.store.list_resources('foo')
       
   178 #        self.assertEquals(files,[])
       
   179 #        files = self.store.list_resources('foo/')
       
   180 #        self.assertEquals(files,[])
       
   181 #        files = self.store.list_resources('foo/bar')
       
   182 #        self.assertEquals(files,[])
       
   183 #
       
   184 #    def test_get_resource(self):
       
   185 #        res = self.store.open_resource('Zoom.confml')
       
   186 ##        resdata = res.read()
       
   187 ##        self.assertTrue(len(resdata) > 0)
       
   188 #
       
   189 #    def test_get_resource_fails(self):
       
   190 #        try:
       
   191 #            res = self.store.open_resource('Zoomi.confml')
       
   192 #            self.fail('Opening non existing resource succeeds')
       
   193 #            
       
   194 #        except exceptions.NotResource, e:
       
   195 #            pass
       
   196 #
       
   197 #    def test_is_resource(self):
       
   198 #        ret = self.store.is_resource('Zoom.confml')
       
   199 #        self.assertTrue(ret)
       
   200 #
       
   201 #    def test_is_resource_false(self):
       
   202 #        ret = self.store.is_resource('Foobar.confml')
       
   203 #        self.assertFalse(ret)
       
   204 
       
   205 class TestCarbonExtapi(unittest.TestCase):
       
   206     def setUp(self):
       
   207         pass
       
   208 
       
   209 #    def test_create_feature(self):
       
   210 #        extapi = webstorage.CarbonExtapi('http://localhost:8000/extapi')
       
   211 #        self.assertTrue(extapi.create_feature('TEST4.featurelist',model.CarbonSetting('TestGroup')))
       
   212 #        self.assertTrue(extapi.create_feature('TEST4.featurelist',model.CarbonBooleanSetting('Child1'), 'TestGroup'))
       
   213 #        self.assertTrue(extapi.create_feature('TEST4.featurelist',model.CarbonBooleanSetting('Child2'), 'TestGroup'))
       
   214 #
       
   215 #    def test_create_feature_fails(self):
       
   216 #        extapi = webstorage.CarbonExtapi('http://localhost:8000/extapi')
       
   217 #        self.assertFalse(extapi.create_feature('TEST4.featurelist',model.CarbonSetting('Foobar2'), 'TestGroup'))
       
   218 #
       
   219 #    def test_create_featurelist(self):
       
   220 #        extapi = webstorage.CarbonExtapi('http://localhost:8000/extapi')
       
   221 #        self.assertTrue(extapi.create_featurelist('TEST.featurelist',model.FeatureList(name='TEST9')))
       
   222 
       
   223 #    def test_update_featurelist(self):
       
   224 #        extapi = webstorage.CarbonExtapi('http://localhost:8000/extapi', password='terytkone09')
       
   225 #        fl = model.FeatureList(name='TEST9')
       
   226 #        fl.add_feature(model.CarbonFeature('Test1'))
       
   227 #        data = persistentjson.dumps(fl)
       
   228 #        data = {"features" :[],
       
   229 #                "version_identifier": "WORKING", 
       
   230 #                "flv_description": "Needs description", 
       
   231 #                "path": "TEST9.confml", 
       
   232 #                "type": "featurelist", 
       
   233 #                "name": "TEST9"}
       
   234 #        print "data %s" % data
       
   235 #        self.assertTrue(extapi.update_resource('TEST9.featurelist',data))
       
   236 
       
   237 #    def test_create_configuration(self):
       
   238 #        extapi = webstorage.CarbonExtapi('http://localhost:8000/extapi', password='terytkone09')
       
   239 #        conf = model.CarbonConfiguration(path='Testing3.confml')
       
   240 #        (success,conf)= extapi.create_configuration('Testing3.configuration',conf)
       
   241 #        self.assertTrue(success)
       
   242 
       
   243 
       
   244 if __name__ == '__main__':
       
   245     unittest.main()
       
   246