Fix cyclic import and add Signer.from_service_account_info (#99)


diff --git a/tests/test__service_account_info.py b/tests/test__service_account_info.py
index 14f659a..4caea95 100644
--- a/tests/test__service_account_info.py
+++ b/tests/test__service_account_info.py
@@ -47,7 +47,7 @@
 
 def test_from_dict_bad_format():
     with pytest.raises(ValueError) as excinfo:
-        _service_account_info.from_dict({})
+        _service_account_info.from_dict({}, require=('meep',))
 
     assert excinfo.match(r'missing fields')
 
diff --git a/tests/test_crypt.py b/tests/test_crypt.py
index fd70f4b..9671230 100644
--- a/tests/test_crypt.py
+++ b/tests/test_crypt.py
@@ -12,8 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import os
 import json
+import os
 
 import mock
 from pyasn1_modules import pem
@@ -199,9 +199,23 @@
         with pytest.raises(ValueError):
             crypt.Signer.from_string(key_bytes)
 
+    def test_from_service_account_info(self):
+        signer = crypt.Signer.from_service_account_info(SERVICE_ACCOUNT_INFO)
+
+        assert signer.key_id == SERVICE_ACCOUNT_INFO[
+            crypt._JSON_FILE_PRIVATE_KEY_ID]
+        assert isinstance(signer._key, rsa.key.PrivateKey)
+
+    def test_from_service_account_info_missing_key(self):
+        with pytest.raises(ValueError) as excinfo:
+            crypt.Signer.from_service_account_info({})
+
+        assert excinfo.match(crypt._JSON_FILE_PRIVATE_KEY)
+
     def test_from_service_account_file(self):
         signer = crypt.Signer.from_service_account_file(
             SERVICE_ACCOUNT_JSON_FILE)
 
-        assert signer.key_id == SERVICE_ACCOUNT_INFO['private_key_id']
+        assert signer.key_id == SERVICE_ACCOUNT_INFO[
+            crypt._JSON_FILE_PRIVATE_KEY_ID]
         assert isinstance(signer._key, rsa.key.PrivateKey)