Repository: iterative/dvc

Issue:
remote: gs: don't forget to set projectname when connecting to gs
Currently we don't set projectname at all, relying on creds file or env vars.

Discussion:

Patch:
diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py
index 4288bf39a..e2abf722f 100644
--- a/dvc/remote/gs.py
+++ b/dvc/remote/gs.py
@@ -42,7 +42,7 @@ class RemoteGS(RemoteBase):
 
     @property
     def gs(self):
-        return storage.Client()
+        return storage.Client(self.projectname)
 
     def get_md5(self, bucket, path):
         import base64


Test patch:
diff --git a/tests/unit/remote/gs.py b/tests/unit/remote/gs.py
new file mode 100644
index 000000000..c159a08ea
--- /dev/null
+++ b/tests/unit/remote/gs.py
@@ -0,0 +1,25 @@
+import mock
+from unittest import TestCase
+
+from dvc.remote.gs import RemoteGS
+
+
+class TestRemoteGS(TestCase):
+    BUCKET = 'bucket'
+    PREFIX = 'prefix'
+    URL = 'gs://{}/{}'.format(BUCKET, PREFIX)
+    PROJECT = 'PROJECT'
+    CONFIG = {'projectname': PROJECT, 'url': URL}
+
+    def test_init(self):
+        remote = RemoteGS(None, self.CONFIG)
+        self.assertEqual(remote.url, self.URL)
+        self.assertEqual(remote.prefix, self.PREFIX)
+        self.assertEqual(remote.bucket, self.BUCKET)
+        self.assertEqual(remote.projectname, self.PROJECT)
+
+    @mock.patch('google.cloud.storage.Client')
+    def test_gs(self, mock_client):
+        remote = RemoteGS(None, self.CONFIG)
+        remote.gs()
+        mock_client.assert_called_with(self.PROJECT)