Beispiel #1
0
    def test_remove_store(self):
        """
        create a store
        create an item with tags in the store
        place a "not allowed" item in the navigation hierarchy
        call the "remove" method of the store
        check if everything has been removed properly
        """

        STORE_PATH = "./test_store/"
        STORAGE_DIR = "storage"
        NEW_ITEM_NAME = "test_item"

        store = self.create_new_store_object(STORE_PATH, STORAGE_DIR)

        filesystem = FileSystemWrapper()

        ## place a new item in the store
        file_path = "%s%s/%s" % (STORE_PATH, STORAGE_DIR, NEW_ITEM_NAME)
        filesystem.create_file(file_path)
        config = ConfigWrapper("../tsresources/conf/tagstore.cfg")
        ## write the new store also to the config
        store_id = config.add_new_store(STORE_PATH)
        ## now tag it manually
        store.add_item_with_tags(NEW_ITEM_NAME, ["should", "not"],
                                 ["get", "this"])

        ## create a new file in a tag-dir to test if it is removed as well
        file_path = "%s%s/%s" % (STORE_PATH, "descriptions/should",
                                 "i_should_not_be_here.file")
        filesystem.create_file(file_path)

        ## now remove the store
        store.remove()
        ##check if this is done properly
        ##this one should not exist ...
        assert (not filesystem.path_exists(file_path))
        ## this path should still exist
        assert (filesystem.path_exists(STORE_PATH))

        self.remove_dir(STORE_PATH, store_id)
        assert (not filesystem.path_exists(STORE_PATH))

        config.remove_store(store_id)
Beispiel #2
0
    def test_remove_store(self):
        """
        create a store
        create an item with tags in the store
        place a "not allowed" item in the navigation hierarchy
        call the "remove" method of the store
        check if everything has been removed properly
        """
        
        STORE_PATH = "./test_store/"
        STORAGE_DIR = "storage"
        NEW_ITEM_NAME = "test_item"
        
        store = self.create_new_store_object(STORE_PATH, STORAGE_DIR)
        
        filesystem = FileSystemWrapper()

         ## place a new item in the store
        file_path = "%s%s/%s" % (STORE_PATH, STORAGE_DIR, NEW_ITEM_NAME)
        filesystem.create_file(file_path)
        config = ConfigWrapper("../tsresources/conf/tagstore.cfg")
        ## write the new store also to the config
        store_id = config.add_new_store(STORE_PATH)
        ## now tag it manually
        store.add_item_with_tags(NEW_ITEM_NAME, ["should", "not"], ["get", "this"])
        
        ## create a new file in a tag-dir to test if it is removed as well
        file_path = "%s%s/%s" % (STORE_PATH, "descriptions/should", "i_should_not_be_here.file")
        filesystem.create_file(file_path)
        
        ## now remove the store 
        store.remove()
        ##check if this is done properly
        ##this one should not exist ...
        assert(not filesystem.path_exists(file_path))
        ## this path should still exist
        assert(filesystem.path_exists(STORE_PATH))

        self.remove_dir(STORE_PATH, store_id)
        assert(not filesystem.path_exists(STORE_PATH))

        config.remove_store(store_id)
Beispiel #3
0
    def test_create_store_move_and_delete_dir(self):
        """
        1. create a new store
        2. store a new item in the store - manually
        3. move the store to a new location
        4. delete the whole directory
        """

        filesystem = FileSystemWrapper()

        NEW_ITEM_NAME = "test_item"

        STORE_PATH = "./test_store/"
        STORAGE_DIR = "storage"

        store = self.create_new_store_object(STORE_PATH, STORAGE_DIR)

        ## place a new item in the store
        file_path = "%s%s/%s" % (STORE_PATH, STORAGE_DIR, NEW_ITEM_NAME)
        filesystem.create_file(file_path)
        config = ConfigWrapper("../tsresources/conf/tagstore.cfg")
        ## write the new store also to the config
        store_id = config.add_new_store(STORE_PATH)

        ## now tag it manually
        store.add_item_with_tags(NEW_ITEM_NAME, ["should", "not"],
                                 ["get", "this"])

        ## now the tag "should" must be a folde in the describing dir
        #        path_to_check = "%sdescribing/should" % STORE_PATH
        path_to_check = "%sdescriptions/should" % STORE_PATH
        print path_to_check
        assert (filesystem.is_directory(path_to_check))

        self.move_store("./test_store/", store_id, "./new_test_store/")
        self.remove_dir("./new_test_store/", store_id)
Beispiel #4
0
    def test_create_store_move_and_delete_dir(self):
        
        """
        1. create a new store
        2. store a new item in the store - manually
        3. move the store to a new location
        4. delete the whole directory
        """
        
        filesystem = FileSystemWrapper()
        
        NEW_ITEM_NAME = "test_item"
        
        STORE_PATH = "./test_store/"
        STORAGE_DIR = "storage"
        
        store = self.create_new_store_object(STORE_PATH, STORAGE_DIR)
        
        ## place a new item in the store
        file_path = "%s%s/%s" % (STORE_PATH, STORAGE_DIR, NEW_ITEM_NAME)
        filesystem.create_file(file_path)
        config = ConfigWrapper("../tsresources/conf/tagstore.cfg")
        ## write the new store also to the config
        store_id = config.add_new_store(STORE_PATH)
        
        ## now tag it manually
        store.add_item_with_tags(NEW_ITEM_NAME, ["should", "not"], ["get", "this"])
        
        ## now the tag "should" must be a folde in the describing dir
#        path_to_check = "%sdescribing/should" % STORE_PATH
        path_to_check = "%sdescriptions/should" % STORE_PATH
        print path_to_check 
        assert(filesystem.is_directory(path_to_check))
        
        self.move_store("./test_store/", store_id, "./new_test_store/")
        self.remove_dir("./new_test_store/", store_id)