import pytest

from bcbio.distributed import objectstore
from bcbio.distributed.objectstore import GoogleDrive


@pytest.fixture
def mock_api(mocker):
    mocker.patch('bcbio.distributed.objectstore.ServiceAccountCredentials')
    mocker.patch('bcbio.distributed.objectstore.Http')
    mocker.patch('bcbio.distributed.objectstore.build')
    mocker.patch('bcbio.distributed.objectstore.http')
    yield None


def test_create_google_drive_service(mock_api):
    service = GoogleDrive()
    assert service


def test_creates_http_auth(mock_api):
    GoogleDrive()
    objectstore.ServiceAccountCredentials.from_json_keyfile_name\
        .assert_called_once_with(
            GoogleDrive.GOOGLE_API_KEY_FILE, scopes=GoogleDrive.SCOPES)


def test_api_scope_includes_google_drive(mock_api):
    drive_scope = 'https://www.googleapis.com/auth/drive'
    assert drive_scope in GoogleDrive.SCOPES

import pytest

from bcbio.distributed import objectstore
from bcbio.distributed.objectstore import GoogleDrive


@pytest.fixture
def mock_api(mocker):
    mocker.patch('bcbio.distributed.objectstore.ServiceAccountCredentials')
    mocker.patch('bcbio.distributed.objectstore.Http')
    mocker.patch('bcbio.distributed.objectstore.build')
    mocker.patch('bcbio.distributed.objectstore.http')
    yield None


def test_create_google_drive_service(mock_api):
    service = GoogleDrive()
    assert service


def test_creates_http_auth(mock_api):
    GoogleDrive()
    objectstore.ServiceAccountCredentials.from_json_keyfile_name\
        .assert_called_once_with(
            GoogleDrive.GOOGLE_API_KEY_FILE, scopes=GoogleDrive.SCOPES)


def test_api_scope_includes_google_drive(mock_api):
    drive_scope = 'https://www.googleapis.com/auth/drive'
    assert drive_scope in GoogleDrive.SCOPES


def test_filename_with_json_key_is_present(mock_api):
    assert GoogleDrive.GOOGLE_API_KEY_FILE
    assert GoogleDrive.GOOGLE_API_KEY_FILE.endswith('.json')

Test json file with api key is in API service class
Test json file with api key is in API service class

  import pytest
  
  from bcbio.distributed import objectstore
  from bcbio.distributed.objectstore import GoogleDrive
  
  
  @pytest.fixture
  def mock_api(mocker):
      mocker.patch('bcbio.distributed.objectstore.ServiceAccountCredentials')
      mocker.patch('bcbio.distributed.objectstore.Http')
      mocker.patch('bcbio.distributed.objectstore.build')
      mocker.patch('bcbio.distributed.objectstore.http')
      yield None
  
  
  def test_create_google_drive_service(mock_api):
      service = GoogleDrive()
      assert service
  
  
  def test_creates_http_auth(mock_api):
      GoogleDrive()
      objectstore.ServiceAccountCredentials.from_json_keyfile_name\
          .assert_called_once_with(
              GoogleDrive.GOOGLE_API_KEY_FILE, scopes=GoogleDrive.SCOPES)
  
  
  def test_api_scope_includes_google_drive(mock_api):
      drive_scope = 'https://www.googleapis.com/auth/drive'
      assert drive_scope in GoogleDrive.SCOPES
  
+ 
+ def test_filename_with_json_key_is_present(mock_api):
+     assert GoogleDrive.GOOGLE_API_KEY_FILE
+     assert GoogleDrive.GOOGLE_API_KEY_FILE.endswith('.json')
+ 
Test json file with api key is in API service class
## Code Before:
import pytest

from bcbio.distributed import objectstore
from bcbio.distributed.objectstore import GoogleDrive


@pytest.fixture
def mock_api(mocker):
    mocker.patch('bcbio.distributed.objectstore.ServiceAccountCredentials')
    mocker.patch('bcbio.distributed.objectstore.Http')
    mocker.patch('bcbio.distributed.objectstore.build')
    mocker.patch('bcbio.distributed.objectstore.http')
    yield None


def test_create_google_drive_service(mock_api):
    service = GoogleDrive()
    assert service


def test_creates_http_auth(mock_api):
    GoogleDrive()
    objectstore.ServiceAccountCredentials.from_json_keyfile_name\
        .assert_called_once_with(
            GoogleDrive.GOOGLE_API_KEY_FILE, scopes=GoogleDrive.SCOPES)


def test_api_scope_includes_google_drive(mock_api):
    drive_scope = 'https://www.googleapis.com/auth/drive'
    assert drive_scope in GoogleDrive.SCOPES

## Instruction:
Test json file with api key is in API service class
## Code After:
import pytest

from bcbio.distributed import objectstore
from bcbio.distributed.objectstore import GoogleDrive


@pytest.fixture
def mock_api(mocker):
    mocker.patch('bcbio.distributed.objectstore.ServiceAccountCredentials')
    mocker.patch('bcbio.distributed.objectstore.Http')
    mocker.patch('bcbio.distributed.objectstore.build')
    mocker.patch('bcbio.distributed.objectstore.http')
    yield None


def test_create_google_drive_service(mock_api):
    service = GoogleDrive()
    assert service


def test_creates_http_auth(mock_api):
    GoogleDrive()
    objectstore.ServiceAccountCredentials.from_json_keyfile_name\
        .assert_called_once_with(
            GoogleDrive.GOOGLE_API_KEY_FILE, scopes=GoogleDrive.SCOPES)


def test_api_scope_includes_google_drive(mock_api):
    drive_scope = 'https://www.googleapis.com/auth/drive'
    assert drive_scope in GoogleDrive.SCOPES


def test_filename_with_json_key_is_present(mock_api):
    assert GoogleDrive.GOOGLE_API_KEY_FILE
    assert GoogleDrive.GOOGLE_API_KEY_FILE.endswith('.json')
