This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from Morgenz/YACHT-1259
YACHT-1259 Add exception handling for on-demand table backup, code re…
- Loading branch information
Showing
7 changed files
with
101 additions
and
60 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
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
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,35 @@ | ||
import unittest | ||
|
||
from mock import patch | ||
from src.backup.datastore.Table import Table | ||
from src.backup.on_demand.on_demand_table_backup import OnDemandTableBackup | ||
from src.commons.big_query.big_query_table_metadata import BigQueryTableMetadata | ||
from src.commons.exceptions import ParameterValidationException | ||
from src.commons.table_reference import TableReference | ||
|
||
|
||
class TestOnDemandTableBackup(unittest.TestCase): | ||
|
||
@patch.object(Table, "get_table", return_value=None) | ||
@patch('src.commons.big_query.big_query_table_metadata.BigQueryTableMetadata.get_table_by_reference', | ||
return_value=BigQueryTableMetadata( | ||
{"tableReference": { | ||
"projectId": "test-project", | ||
"datasetId": "test-dataset", | ||
"tableId": "test-table-without-partition" | ||
}, | ||
"timePartitioning": { | ||
"type": "DAY" | ||
}} | ||
)) | ||
def test_should_throw_parameter_validation_exception_if_table_is_partitioned_but_partition_number_was_not_given( | ||
self, _1, _2): | ||
# given | ||
table_reference = TableReference(project_id="test-project", | ||
dataset_id="test-dataset", | ||
table_id="test-table", | ||
partition_id="") | ||
|
||
# when-then | ||
with self.assertRaises(ParameterValidationException): | ||
OnDemandTableBackup.start(table_reference) |
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