Example #1
0
    def test_rename_happy(self):
        rename_key_old = 'test_file'
        rename_key_new = 'test_file_changed'
        set_data = [(basestring, rename_key_old, rename_key_old, False)]
        get_data = [(basestring, '{0}/'.format(rename_key_old), rename_key_old, False)]
        self._assert_set_get(set_data, get_data)
        Configuration.rename(rename_key_old, rename_key_new)

        self.assertEquals(Configuration.get(rename_key_new), rename_key_old)
        with self.assertRaises(ConfigurationNotFoundException):
            Configuration.get('test_folder/test_file_changed')  # This key should not be made
        with self.assertRaises(ConfigurationNotFoundException):
            Configuration.get(rename_key_old)   # This key cannot exist anymore
Example #2
0
    def test_rename_unhappy(self):
        """
        Test made to prevent wrongly joined paths when an '_' occurred at the end of a key
        """
        rename_key_old = 'test_folder'
        rename_key_new = 'test_folder_changed'
        set_data = [(basestring, '{0}_'.format(rename_key_old), rename_key_old, False), (basestring, '{0}_/test_file'.format(rename_key_old), rename_key_old, False)]
        get_data = [(basestring, '/{0}_'.format(rename_key_old), rename_key_old, False), (basestring, '/{0}_/test_file'.format(rename_key_old), rename_key_old, False)]
        self._assert_set_get(set_data, get_data)
        Configuration.rename(rename_key_old, rename_key_new)

        c = Configuration.get_client()
        entries = c.prefix_entries(rename_key_old)
        self.assertTrue(Configuration.get('{0}_'.format(rename_key_old)) == rename_key_old)  # None of these keys should be renamed
        self.assertTrue(Configuration.get('{0}_/test_file'.format(rename_key_old)) == rename_key_old)
        self.assertFalse(any(['/../' in i[0] for i in entries]), 'Error during joining of prefixes')  # Check if joining error happened in some key
Example #3
0
 def test_jeff(self):
     Configuration.set('djef/test', 'test_content')
     Configuration.set('djef_test1', 'test_content')
     Configuration.rename('djef', 'djef2')
     c = Configuration.get_client()
     self.assertListEqual(c.prefix_entries('djef'), [('djef_test1', '"test_content"'), ('djef2/test', '"test_content"')])