Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into sa-use-try-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Abadie authored Mar 18, 2019
2 parents 03c7a0c + b08d875 commit 339bf28
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/staticanalysis/bot/static_analysis_bot/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ def as_dict(self):
Outputs a serializable representation of this revision
'''
return {
'source': 'phabricator',
'diff_phid': self.diff_phid,
'phid': self.phid,
'diff_id': self.diff_id,
Expand Down
5 changes: 5 additions & 0 deletions src/staticanalysis/bot/static_analysis_bot/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ def index(self, revision, **kwargs):
now = datetime.utcnow()
payload['indexed'] = now.strftime(TASKCLUSTER_DATE_FORMAT)

# Always add the source and try config
payload['source'] = settings.source
payload['try_task_id'] = settings.try_task_id
payload['try_group_id'] = settings.try_group_id

# Add a sub namespace with the task id to be able to list
# tasks from the parent namespace
namespaces = revision.namespaces + [
Expand Down
2 changes: 1 addition & 1 deletion src/staticanalysis/bot/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def mock_config():
return build_config()


@pytest.fixture(scope='function')
@pytest.fixture(scope='class')
def mock_try_config():
'''
Mock configuration for bot
Expand Down
1 change: 0 additions & 1 deletion src/staticanalysis/bot/tests/test_reporter_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_publication(tmpdir, mock_issues, mock_phabricator):

assert 'revision' in report
assert report['revision'] == {
'source': 'phabricator',
'id': 51,
'diff_id': 42,
'url': 'https://phabricator.test/D51',
Expand Down
16 changes: 11 additions & 5 deletions src/staticanalysis/bot/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
from unittest import mock


def test_taskcluster_index(mock_workflow, mock_config):
def test_taskcluster_index(mock_workflow, mock_try_config):
'''
Test the Taskcluster indexing API
by mocking an online taskcluster state
'''
from static_analysis_bot.config import TaskCluster
from static_analysis_bot.revisions import Revision
mock_config.taskcluster = TaskCluster('/tmp/dummy', '12345deadbeef', 0, False)
mock_try_config.taskcluster = TaskCluster('/tmp/dummy', '12345deadbeef', 0, False)
mock_workflow.index_service = mock.Mock()
rev = Revision()
rev.namespaces = ['mock.1234']
rev.as_dict = lambda: {'id': '1234', 'source': 'mock'}
rev.as_dict = lambda: {'id': '1234', 'someData': 'mock'}
mock_workflow.index(rev, test='dummy')

assert mock_workflow.index_service.insertTask.call_count == 2
Expand All @@ -29,7 +29,10 @@ def test_taskcluster_index(mock_workflow, mock_config):
assert args['taskId'] == '12345deadbeef'
assert args['data']['test'] == 'dummy'
assert args['data']['id'] == '1234'
assert args['data']['source'] == 'mock'
assert args['data']['source'] == 'try'
assert args['data']['try_task_id'] == 'remoteTryTask'
assert args['data']['try_group_id'] == 'remoteTryGroup'
assert args['data']['someData'] == 'mock'
assert 'indexed' in args['data']

# Second call with sub namespace
Expand All @@ -38,5 +41,8 @@ def test_taskcluster_index(mock_workflow, mock_config):
assert args['taskId'] == '12345deadbeef'
assert args['data']['test'] == 'dummy'
assert args['data']['id'] == '1234'
assert args['data']['source'] == 'mock'
assert args['data']['source'] == 'try'
assert args['data']['try_task_id'] == 'remoteTryTask'
assert args['data']['try_group_id'] == 'remoteTryGroup'
assert args['data']['someData'] == 'mock'
assert 'indexed' in args['data']

0 comments on commit 339bf28

Please sign in to comment.