# -*- coding: utf-8 -*-
"""
Tests for gstorage.storage
"""
from mock import patch
from unittest import TestCase

from gstorage.storage import Storage


@patch('gstorage.storage.Bucket.get_default')
class TestStorage(TestCase):

    @patch('gstorage.storage.Blob')
    def test_save_no_location(self, mock_blob, mock_bucket):
        s = Storage()
        s._save('test.jpg', None)
        mock_blob.assert_called_once_with('test.jpg', mock_bucket())

    @patch('gstorage.storage.Blob')
    def test_save_with_location(self, mock_blob, mock_bucket):
        s = Storage(location='images')
        s._save('test.jpg', None)
        mock_blob.assert_called_once_with('images/test.jpg', mock_bucket())

    @patch('gstorage.storage.Blob')
    def test_open(self, mock_blob, mock_bucket):
        s = Storage()
        s._save('test.jpg', 'r')
        mock_blob.assert_called_once_with('test.jpg', mock_bucket())

    def test_get_valid_name(self, mock_bucket):
        s = Storage()
        assert s.get_valid_name('test.jpg') == 'test.jpg'

@@ -68,16 +68,27 @@
 k import
+ MagicMock,
  patch%0Af
@@ -922,128 +922,1454 @@
     
-def test_get_valid_name(self, mock_bucket):%0A        s = Storage()%0A        assert s.get_valid_name('test.jpg') == 'test.jpg'
+@patch('gstorage.storage.Blob')%0A    def test_exists(self, mock_blob, mock_bucket):%0A        mock_blob.exists = MagicMock()%0A        s = Storage()%0A        s.url('test.jpg')%0A        mock_blob.exists.call_count == 1%0A%0A    @patch('gstorage.storage.Blob')%0A    def test_url(self, mock_blob, mock_bucket):%0A        mock_blob.public_url = MagicMock()%0A        s = Storage()%0A        s.url('test.jpg')%0A        mock_blob.public_url.call_count == 1%0A%0A    @patch('gstorage.storage.Blob.exists')%0A    def test_available_name(self, mock_exists, mock_bucket):%0A        mock_exists.return_value = False%0A        s = Storage()%0A        assert s.get_available_name('test.jpg') == 'test.jpg'%0A%0A    def test_valid_name(self, mock_bucket):%0A        s = Storage()%0A        assert s.get_valid_name('test.jpg') == 'test.jpg'%0A%0A    def test_not_implemented(self, mock_bucket):%0A        s = Storage()%0A        with self.assertRaises(NotImplementedError):%0A            s.listdir('test')%0A        with self.assertRaises(NotImplementedError):%0A            s.path('test')%0A        with self.assertRaises(NotImplementedError):%0A            s.delete('test')%0A        with self.assertRaises(NotImplementedError):%0A            s.size('test')%0A        with self.assertRaises(NotImplementedError):%0A            s.accessed_time('test')%0A        with self.assertRaises(NotImplementedError):%0A            s.created_time('test')%0A        with self.assertRaises(NotImplementedError):%0A            s.modified_time('test')
 %0A

Add more tests