Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

YACHT-917: Removed redundant parameters from configuration #133

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,3 @@ project_settings:

# default_restoration_project_id - project into which data will be restored by default during restoration process
# default_restoration_project_id: 'default-restoration-storage-project-id'

tests:
random_table_view: 'project:dataset.table'
25 changes: 0 additions & 25 deletions src/commons/big_query/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,6 @@ def create_partition_query(project_id, dataset_id, table_id):
" AS last_modified FROM [{0}:{1}.{2}$__PARTITIONS_SUMMARY__]" \
.format(project_id, dataset_id, table_id)

@log_time
def fetch_random_table(self):
query_results = self.__sync_query(
query=self.random_table_from_project_query(),
use_legacy_sql=True)

if query_results and 'totalRows' in query_results \
and int(query_results['totalRows']) > 0:
results = []
results.extend(query_results.get('rows', []))
first_row = results[0]
project_id = first_row['f'][2]['v']
dataset_id = first_row['f'][1]['v']
table_id = first_row['f'][0]['v']
table_reference = TableReference(project_id, dataset_id, table_id)
else:
raise RandomizationError(
"No results returned from randomization query")
return table_reference

@staticmethod
def random_table_from_project_query():
return "SELECT tableId, datasetId, projectId FROM [{}]" \
.format(configuration.restoration_daily_test_random_table_view)

def __sync_query(self, query, timeout=30000, use_legacy_sql=False):
query_data = {
'query': query,
Expand Down
4 changes: 0 additions & 4 deletions src/commons/config/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def default_restoration_project_id(self):
def projects_to_skip(self):
return self.__project_config['backup_settings'].get('projects_to_skip')

@property
def restoration_daily_test_random_table_view(self):
return self.__project_config['tests'].get('random_table_view')


config_file_yaml = "config/config.yaml"
logging.info("Loading configuration from file: '%s'", config_file_yaml)
Expand Down
21 changes: 0 additions & 21 deletions tests/commons/big_query/test_big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,6 @@ def test_listing_table_partitions(self, _):
self.assertEqual(partitions[0]['lastModifiedTime'],
'2017-03-17 14:32:19.289000')

@patch.object(BigQuery, '_create_credentials', return_value=None)
def test_should_fetch_single_result_from_random_table_query(self, _):
# given
self._create_http.return_value = self.__create_random_table_responses()
# when
random_table = BigQuery().fetch_random_table()

# then
self.assertEqual('project-dev', random_table.get_project_id())
self.assertEqual('test_set', random_table.get_dataset_id())
self.assertEqual('O_PRODUCT_SUPPLIER_20151127',
random_table.get_table_id())

@patch.object(BigQuery, '_create_credentials', return_value=None)
def test_get_dataset_cached_should_only_call_bq_once_but_response_is_cached(
self, _):
Expand All @@ -151,14 +138,6 @@ def test_get_dataset_cached_should_only_call_bq_once_but_response_is_cached(
# then
self.assertEqual(result1, result2)

@patch.object(BigQuery, '_create_credentials', return_value=None)
def test_should_raise_exception_if_random_table_query_returns_no_results(
self, _):
# given
self._create_http.return_value = self.__create_random_table_no_results_responses()
# when then
self.assertRaises(RandomizationError, BigQuery().fetch_random_table)

@patch.object(BigQuery, '_create_credentials', return_value=None)
def test_create_dataset_happy_path(self, _):
# given
Expand Down