-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TDL-14397-Add skipped log when first row is empty #46
Merged
prijendev
merged 6 commits into
TDL-15623-Crest-Master
from
TDL-14397-skipped-sheet-log-when-empty
Dec 13, 2021
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3682329
added logger message and unittests
77fa727
added code comments
1128a8c
changed the logger message and logic
2cd5677
Merge branch 'TDL-15623-Crest-Master' of https://github.com/singer-io…
namrata270998 85b48e7
resolved comments
namrata270998 479a0e5
Merge remote-tracking branch 'origin/TDL-15623-Crest-Master' into TDL…
prijendev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,78 @@ | ||
import unittest | ||
from unittest.case import TestCase | ||
from unittest import mock | ||
import tap_google_sheets | ||
from tap_google_sheets import schema | ||
|
||
|
||
class TestLogger(unittest.TestCase): | ||
@mock.patch('tap_google_sheets.schema.LOGGER.warn') | ||
def test_logger_message(self, mocked_logger): | ||
""" | ||
Test if the logger statement is printed when the header row is empty and the sheet is being skipped. | ||
""" | ||
sheet_data = { | ||
"properties":{ | ||
"sheetId":2074712559, | ||
"title":"Sheet5", | ||
"index":1, | ||
"sheetType":"GRID", | ||
"gridProperties":{ | ||
"rowCount":1000, | ||
"columnCount":26 | ||
} | ||
}, | ||
"data":[ | ||
{ | ||
"rowData":[ | ||
{}, | ||
{ | ||
"values":[ | ||
{ | ||
"userEnteredValue":{ | ||
"numberValue":1 | ||
}, | ||
"effectiveValue":{ | ||
"numberValue":1 | ||
}, | ||
"formattedValue":"1", | ||
}, | ||
{ | ||
"userEnteredValue":{ | ||
"numberValue":2 | ||
}, | ||
"effectiveValue":{ | ||
"numberValue":2 | ||
}, | ||
"formattedValue":"2" | ||
}, | ||
{ | ||
"userEnteredValue":{ | ||
"numberValue":3 | ||
}, | ||
"effectiveValue":{ | ||
"numberValue":3 | ||
}, | ||
"formattedValue":"3", | ||
} | ||
] | ||
} | ||
], | ||
"rowMetadata":[ | ||
{ | ||
"pixelSize":21 | ||
} | ||
], | ||
"columnMetadata":[ | ||
{ | ||
"pixelSize":100 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
# retrieve the sheet title from the `sheet_data` | ||
sheet_title = sheet_data.get('properties', {}).get('title') | ||
sheet_schema, columns = schema.get_sheet_schema_columns(sheet_data) | ||
# check if the logger is called with correct logger message | ||
mocked_logger.assert_called_with('SKIPPING THE SHEET AS HEADERS ROW IS EMPTY. SHEET: {}'.format(sheet_title)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the unnecessary import of
TestCase
as the test case usesunittest.TestCase
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done