Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Fix 744/dokuwik conversions still have wrong language code in manifes…
Browse files Browse the repository at this point in the history
…t table (#172)

* ClientWebhook - fix for manifest changes not persisted.

* TestClientWebhook - added unit test to check for manifest table data update.
  • Loading branch information
PhotoNomad0 authored and richmahn committed Sep 27, 2017
1 parent 2599001 commit 7f70867
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions libraries/client/client_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def process_webhook(self):
for key, value in manifest_data.iteritems():
setattr(tx_manifest, key, value)
App.logger.debug('Updating manifest in manifest table: {0}'.format(manifest_data))
tx_manifest.update()
else:
tx_manifest = TxManifest(**manifest_data)
App.logger.debug('Inserting manifest into manifest table: {0}'.format(tx_manifest))
Expand Down
37 changes: 37 additions & 0 deletions tests/client_tests/test_client_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,43 @@ def test_processWebhookError(self, mock_send_payload_to_run_linter, mock_downloa
# then
self.validateResults(self.get_build_log_json(), expected_job_count, expected_error_count)

@patch('libraries.client.client_webhook.download_file')
@patch('libraries.client.client_webhook.ClientWebhook.send_payload_to_run_linter')
def test_processWebhook_update_manifest_table(self, mock_send_payload_to_run_linter, mock_download_file):
# given
manifest_data = {
'resource_id': ' ',
'title': ' ',
'manifest': ' ',
'lang_code': ' ',
'user_name': 'tx-manager-test-data',
'resource_type': ' ',
'repo_name': 'en-ulb'}
tx_manifest = TxManifest(**manifest_data)
tx_manifest.insert() # preload table with empty data
mock_send_payload_to_run_linter.return_value = {'success': True, 'warnings': []}
client_web_hook = self.setup_client_webhook_mock('kpb_mat_text_udb_repo', self.parent_resources_dir,
mock_download_file)
expected_job_count = 1
expected_error_count = 0

# when
results = client_web_hook.process_webhook()

# then
self.validateResults(results, expected_job_count, expected_error_count)

# Check repo was updated in manifest table
repo_name = client_web_hook.commit_data['repository']['name']
user_name = client_web_hook.commit_data['repository']['owner']['username']
tx_manifest = TxManifest.get(repo_name=repo_name, user_name=user_name)
self.assertEqual(tx_manifest.repo_name, client_web_hook.commit_data['repository']['name'])
self.assertEqual(tx_manifest.resource_id, 'udb')
self.assertEqual(tx_manifest.lang_code, 'kpb')
self.assertEqual(tx_manifest.title, 'Unlocked Dynamic Bible')
self.assertEqual(tx_manifest.resource_type, 'book')
self.assertGreater(len(tx_manifest.manifest), 100)

@patch('libraries.client.client_webhook.download_file')
@patch('libraries.client.client_webhook.ClientWebhook.send_payload_to_run_linter')
def test_processWebhookMultipleBooks(self, mock_send_payload_to_run_linter, mock_download_file):
Expand Down

0 comments on commit 7f70867

Please sign in to comment.