BelminH / regular.river

An automated bank transaction categorizer that inserts the data into Google sheets using their API
MIT License
0 stars 0 forks source link

update test_update_sheet since client secret is not pushed to github #53

Closed BelminH closed 6 months ago

BelminH commented 6 months ago

__ test_update_sheet ___

mock_service = mock_datetime =

def test_update_sheet(mock_service, mock_datetime):
    # Mock the return value of return_credentials function
    with patch("main.return_credentials") as mock_credentials:
        mock_credentials.return_value = ("spreadsheet_id", "sheet_name", "sheet_id")

        # Set up the mock service objects
        mock_sheets_service = MagicMock()
        mock_service.return_value = mock_sheets_service
        mock_values = MagicMock()
        mock_sheets_service.spreadsheets.return_value.values.return_value = mock_values
        mock_batch_update = MagicMock()
        mock_sheets_service.spreadsheets.return_value.batchUpdate.return_value = (
            mock_batch_update
        )

        # Call the function under test
      update_sheet({"example_total": 100.0})

tests/main_test.py:188:


main.py:202: in update_sheet credentials = service_account.Credentials.from_service_account_file( ../../../.local/lib/python3.10/site-packages/google/oauth2/service_account.py:258: in from_service_account_file info, signer = _service_account_info.from_filename(


filename = 'config/client_secret.json', require = ['client_email', 'token_uri'] use_rsa_signer = True

def from_filename(filename, require=None, use_rsa_signer=True):
    """Reads a Google service account JSON file and returns its parsed info.

    Args:
        filename (str): The path to the service account .json file.
        require (Sequence[str]): List of keys required to be present in the
            info.
        use_rsa_signer (Optional[bool]): Whether to use RSA signer or EC signer.
            We use RSA signer by default.

    Returns:
        Tuple[ Mapping[str, str], google.auth.crypt.Signer ]: The verified
            info and a signer instance.
    """
  with io.open(filename, "r", encoding="utf-8") as json_file:

E FileNotFoundError: [Errno 2] No such file or directory: 'config/client_secret.json'

../../../.local/lib/python3.10/site-packages/google/auth/_service_account_info.py:78: FileNotFoundError

---------- coverage: platform linux, python 3.10.12-final-0 ---------- Coverage XML written to file coverage.xml

=========================== short test summary info ============================ FAILED tests/main_test.py::test_update_sheet - FileNotFoundError: [Errno 2] No such file or directory: 'config/client_secret.json'