def test_getStoredSearches_should_call_retrieve_to_get_searches(self):
        storage = YouTubeStorage()
        storage.retrieveSettings = Mock()
        storage.retrieveSettings.return_value = ["some_search"]
        storage.storeSettings = Mock()

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

        assert storage.retrieveSettings.call_count > 0
    def test_getStoredSearches_should_call_retrieve_to_get_thumbnail_collection(self):
        storage = YouTubeStorage()
        storage.retrieveSettings = Mock()
        storage.retrieveSettings.return_value = ["some_search"]
        storage.storeSettings = Mock()

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

        assert storage.retrieveSettings.call_args[0][0] == {"path": "some_path"}
        assert storage.retrieveSettings.call_args[0][1] == "thumbnail"
        assert storage.retrieveSettings.call_args[0][2] == {
            "path": "some_path",
            "search": "some_search",
            "thumbnail": ["some_search"],
            "Title": "some_search",
        }
        assert storage.retrieveSettings.call_count == 2
    def test_list_should_call_getStoredSearches_if_store_is_defined_in_params_but_not_artist_or_contact_option(self):
        storage = YouTubeStorage()
        storage.getStoredSearches = Mock()
        storage.getStoredSearches.return_value = ("", 200)

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

        storage.getStoredSearches.assert_called_with({"store": "somestore"})
    def test_getStoredSearches_should_return_proper_list_structure(self):
        storage = YouTubeStorage()
        storage.retrieveSettings = Mock()
        storage.retrieveSettings.return_value = ["some_search"]
        storage.storeSettings = Mock()

        (result, status) = 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_return_proper_list_structure(self):
        storage = YouTubeStorage()
        storage.retrieveSettings = Mock()
        storage.retrieveSettings.return_value = ["some_search"]
        storage.storeSettings = Mock()

        (result, status) = 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_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 = YouTubeStorage()
        storage.retrieveSettings = Mock()
        storage.retrieveSettings.return_value = ["some_search"]
        storage.storeSettings = Mock()

        (result, status) = 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"}
        ]
    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 = YouTubeStorage()
        storage.retrieveSettings = Mock()
        storage.retrieveSettings.return_value = ["some_search"]
        storage.storeSettings = Mock()

        (result, status) = 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'
        }])