def test_getStoredSearches_should_call_retrieve_to_get_searches(self):
        storage = BlipTVStorage()
        storage.retrieveValue = Mock()
        storage.retrieveValue.return_value = repr(["some_search"])
        storage.retrieve = Mock()
        storage.retrieve.return_value = ["some_search"]
        storage.store = Mock()

        storage.getStoredSearches({"path": "some_path"})

        assert(storage.retrieve.call_count > 0)
    def test_getStoredSearches_should_call_retrieve_to_get_thumbnail_collection(self):
        storage = BlipTVStorage()
        storage.retrieveValue = Mock()
        storage.retrieveValue.return_value = ["some_search"]
        storage.retrieve = Mock()
        storage.retrieve.return_value = ["some_search"]
        storage.store = Mock()

        storage.getStoredSearches({"path": "some_path"})
        assert(storage.retrieve.call_args[0][0] == {"path": "some_path"})
        assert(storage.retrieve.call_args[0][1] == "thumbnail")
        print repr(storage.retrieve.call_args[0][2])
        assert(storage.retrieve.call_args[0][2] == {'path': 'some_path', 'search': 'some_search', 'thumbnail': ['some_search'], 'Title': 'some_search'})
        assert(storage.retrieve.call_count == 2)
    def test_list_should_call_getStoredSearches_if_store_is_searches(self):
        storage = BlipTVStorage()
        storage.getStoredSearches = Mock()
        storage.getStoredSearches.return_value = ""

        storage.list({"store": "searches"})

        storage.getStoredSearches.assert_called_with({"store": "searches"})
    def test_getStoredSearches_should_return_proper_list_structure(self):
        storage = BlipTVStorage()
        storage.retrieveValue = Mock()
        storage.retrieveValue.return_value = ["some_search"]
        storage.retrieve = Mock()
        storage.retrieve.return_value = ["some_search"]
        storage.store = Mock()

        result = storage.getStoredSearches({"path": "some_path"})

        print repr(result)
        assert(result == [{'path': 'some_path', 'search': 'some_search', 'thumbnail': ['some_search'], 'Title': 'some_search'}])
    def test_getStoredSearches_should_fill_item_for_store_search(self):
        patcher = patch("urllib.quote_plus")
        patcher.start()
        import urllib
        urllib.quote_plus.return_value = "some_quoted_search"
        storage = BlipTVStorage()
        storage.retrieveValue = Mock()
        storage.retrieveValue.return_value = ["some_search"]
        storage.retrieve = Mock()
        storage.retrieve.return_value = ["some_search"]
        storage.store = Mock()

        result = storage.getStoredSearches({"path": "some_path", "store": "searches"})

        args = urllib.quote_plus.call_args
        patcher.stop()
        print repr(result)
        assert(args[0][0] == "some_search")
        assert(result == [{'feed': 'search', 'search': 'some_quoted_search', 'Title': 'some_search', 'scraper': 'search', 'path': 'some_path', 'thumbnail': ['some_search'], 'icon': 'search'}])
    def test_getStoredSearches_should_call_quote_plus_on_search_items(self):
        patcher = patch("urllib.quote_plus")
        patcher.start()
        import urllib
        urllib.quote_plus.return_value = "some_quoted_search"
        storage = BlipTVStorage()
        storage.retrieveValue = Mock()
        storage.retrieveValue.return_value = ["some_search"]
        storage.retrieve = Mock()
        storage.retrieve.return_value = ["some_search"]
        storage.store = Mock()
        
        result = storage.getStoredSearches({"path": "some_path"})

        args = urllib.quote_plus.call_args
        patcher.stop()

        assert(args[0][0] == "some_search")
        assert(result == [{'path': 'some_path', 'search': 'some_quoted_search', 'thumbnail': ['some_search'], 'Title': 'some_search'}])