-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new sheets v4 api to fetch budget data
- Loading branch information
Showing
8 changed files
with
99 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/reports/ | ||
/credentials.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,14 @@ TRIPLETEX_EMPLOYEE_TOKEN=xxx | |
# defaults to $PWD/reports/ | ||
REPORTS_DIR=/var/okoreports/reports/ | ||
# this is the link to a Google Spreadsheet feed - the document must be published for this to work | ||
# e.g. https://spreadsheets.google.com/feeds/worksheets/1pAEq8O5NMkmEWvW-c6x_47abg5IO7HqPO5bs5J-iPt4/public/full?alt=json | ||
# set to None to disable budget | ||
OKOREPORTS_BUDGET_URL=xxx | ||
# Path to Google Cloud Service Account credentials file. | ||
# As of writing, we use credentials for [email protected] | ||
OKOREPORTS_BUDGET_CREDENTIALS_FILE=xxx | ||
# the URL the user can go to and edit the spreadsheet | ||
OKOREPORTS_BUDGET_EDIT_URL=xxx | ||
# ID to a Google Spreadsheet | ||
# e.g. 1pAEq8O5NMkmEWvW-c6x_47abg5IO7HqPO5bs5J-iPt4 | ||
# set to None to disable budget | ||
OKOREPORTS_BUDGET_SPREADSHEET_ID=xxx | ||
``` | ||
|
||
Make sure you have Python 3.10 or newer. | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import io | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
|
||
from app import fetch_budget_data | ||
|
||
load_dotenv() | ||
|
||
budget_credentials_file = os.environ.get("OKOREPORTS_BUDGET_CREDENTIALS_FILE", None) | ||
budget_spreadsheet_id = os.environ.get("OKOREPORTS_BUDGET_SPREADSHEET_ID", None) | ||
|
||
class TestBudget: | ||
def test_budget(self): | ||
out = io.StringIO() | ||
|
||
edit_url = fetch_budget_data.export_budget( | ||
spreadsheet_id=budget_spreadsheet_id, | ||
credentials_file=budget_credentials_file, | ||
output_handle=out, | ||
) | ||
|
||
print(out.getvalue()) | ||
print(edit_url) | ||
|
||
def test_get_name_from_range(self): | ||
assert fetch_budget_data.get_name_from_range("'Something'!A1:C3") == "Something" | ||
assert fetch_budget_data.get_name_from_range("Something!A1:C3") == "Something" | ||
assert fetch_budget_data.get_name_from_range("Something") == "Something" |