diff --git a/README.md b/README.md
index 3a549f852..f865724b3 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,7 @@ Each enriched index includes one or more types of documents, which are summarize
- **Jenkins**: each document corresponds to a single built.
- **Jira**: each document corresponds to an issue or a comment. To simplify counting user activities, issues are duplicated and they can include assignee, reporter and creator data respectively.
- **Kitsune**: each document can be either a question or an answer.
+- **Launchpad**: each document corresponds to a bug.
- **Mattermost**: each document corresponds to a message.
- **Mbox**: each document corresponds to a message.
- **Mediawiki**: each document corresponds to a review.
diff --git a/grimoire_elk/enriched/launchpad.py b/grimoire_elk/enriched/launchpad.py
new file mode 100644
index 000000000..9a1ae4bf7
--- /dev/null
+++ b/grimoire_elk/enriched/launchpad.py
@@ -0,0 +1,203 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015-2020 Bitergia
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+# Authors:
+# Nitish Gupta
+#
+
+import logging
+
+from grimoirelab_toolkit.datetime import (datetime_utcnow)
+
+from .utils import get_time_diff_days
+
+from .enrich import Enrich, metadata
+from ..elastic_mapping import Mapping as BaseMapping
+
+logger = logging.getLogger(__name__)
+
+
+class Mapping(BaseMapping):
+
+ @staticmethod
+ def get_elastic_mappings(es_major):
+ """Get Elasticsearch mapping.
+
+ geopoints type is not created in dynamic mapping
+
+ :param es_major: major version of Elasticsearch, as string
+ :returns: dictionary with a key, 'items', with the mapping
+ """
+
+ mapping = """
+ {
+ "properties": {
+ "description_analyzed": {
+ "type": "text",
+ "index": true
+ }
+ }
+ }
+ """
+ return {"items": mapping}
+
+
+class LaunchpadEnrich(Enrich):
+
+ mapping = Mapping
+ roles = ['assignee_data', 'owner_data']
+
+ def __init__(self, db_sortinghat=None, db_projects_map=None, json_projects_map=None,
+ db_user='', db_password='', db_host=''):
+ super().__init__(db_sortinghat, db_projects_map, json_projects_map,
+ db_user, db_password, db_host)
+
+ def get_field_author(self):
+ return "owner_data"
+
+ def set_elastic(self, elastic):
+ self.elastic = elastic
+
+ def get_sh_identity(self, item, identity_field=None):
+ """ Return a Sorting Hat identity using launchpad user data """
+
+ identity = {
+ 'username': None,
+ 'name': None,
+ 'email': None
+ }
+
+ item = item['data']
+ if isinstance(item, dict) and identity_field in item:
+ identity['username'] = item[identity_field].get('name', None)
+ identity['name'] = item[identity_field].get('display_name', None)
+
+ return identity
+
+ def get_identities(self, item):
+ """ Return the identities from an item """
+
+ for rol in self.roles:
+ if rol in item['data']:
+ user = self.get_sh_identity(item, rol)
+ yield user
+
+ @metadata
+ def get_rich_item(self, item):
+
+ eitem = {}
+
+ self.copy_raw_fields(self.RAW_FIELDS_COPY, item, eitem)
+
+ # data fields to copy
+ copy_fields = ["title", "web_link", "date_created", "date_incomplete", "is_complete",
+ "status", "bug_target_name", "importance", "date_triaged", "date_left_new"]
+
+ bug = item['data']
+ self.copy_raw_fields(copy_fields, bug, eitem)
+
+ if self.sortinghat:
+ eitem.update(self.get_item_sh(item, self.roles))
+
+ if self.prjs_map:
+ eitem.update(self.get_item_project(eitem))
+
+ eitem.update(self.__get_rich_bugs(bug))
+ eitem.update(self.get_grimoire_fields(bug["date_created"], "issue"))
+
+ return eitem
+
+ def __get_rich_bugs(self, data):
+ """Create enriched data for bugs"""
+
+ rich_bugtask = {}
+
+ # Time to
+ if not data["is_complete"]:
+ rich_bugtask["time_open_days"] = get_time_diff_days(data['date_created'], datetime_utcnow().replace(tzinfo=None))
+ else:
+ rich_bugtask["time_open_days"] = get_time_diff_days(data['date_created'], data['date_closed'])
+ rich_bugtask["time_created_to_assigned"] = get_time_diff_days(data['date_created'], data['date_assigned'])
+ rich_bugtask['time_assigned_to_closed'] = get_time_diff_days(data['date_assigned'], data['date_closed'])
+ rich_bugtask["time_to_close_days"] = get_time_diff_days(data['date_created'], data['date_closed'])
+
+ if data['activity_data']:
+ rich_bugtask['time_to_last_update_days'] = \
+ get_time_diff_days(data['date_created'], data['activity_data'][-1]['datechanged'])
+
+ rich_bugtask['reopened'] = 1 if data['date_left_closed'] else 0
+ rich_bugtask['time_to_fix_commit'] = get_time_diff_days(data['date_created'], data['date_fix_committed'])
+ rich_bugtask['time_worked_on'] = get_time_diff_days(data['date_in_progress'], data['date_fix_committed'])
+ rich_bugtask['time_to_confirm'] = get_time_diff_days(data['date_created'], data['date_confirmed'])
+
+ # Author and assignee data
+ owner = data.get('owner_data', None)
+ if owner:
+ rich_bugtask['user_login'] = owner.get('name', None)
+ rich_bugtask['user_name'] = owner.get('display_name', None)
+ rich_bugtask['user_joined'] = owner.get('date_created', None)
+ rich_bugtask['user_karma'] = owner.get('karma', None)
+ rich_bugtask['user_time_zone'] = owner.get('time_zone', None)
+
+ assignee = data.get('assignee_data', None)
+ if assignee:
+ assignee = data['assignee_data']
+ rich_bugtask['assignee_login'] = assignee.get('name', None)
+ rich_bugtask['assignee_name'] = assignee.get('display_name', None)
+ rich_bugtask['assignee_joined'] = assignee.get('date_created', None)
+ rich_bugtask['assignee_karma'] = assignee.get('karma', None)
+ rich_bugtask['assignee_time_zone'] = assignee.get('time_zone', None)
+
+ # Extract info related to bug
+ rich_bugtask.update(self.__extract_bug_info(data['bug_data']))
+
+ rich_bugtask['time_to_first_attention'] = \
+ get_time_diff_days(data['date_created'], self.get_time_to_first_attention(data))
+ rich_bugtask['activity_count'] = len(data['activity_data'])
+
+ return rich_bugtask
+
+ def __extract_bug_info(self, bug_data):
+
+ rich_bug_info = {}
+
+ copy_fields = ["latest_patch_uploaded", "security_related", "private", "users_affected_count",
+ "title", "description", "tags", "date_last_updated", "message_count", "heat"]
+ rich_bug_info['time_created_to_last_update_days'] = \
+ get_time_diff_days(bug_data['date_created'], bug_data['date_last_updated'])
+
+ rich_bug_info['description'] = bug_data['description'][:self.KEYWORD_MAX_LENGTH]
+ rich_bug_info['description_analyzed'] = bug_data['description']
+ rich_bug_info['bug_name'] = bug_data['name']
+ rich_bug_info['bug_id'] = bug_data['id']
+
+ self.copy_raw_fields(copy_fields, bug_data, rich_bug_info)
+
+ return rich_bug_info
+
+ def get_time_to_first_attention(self, item):
+ """Get the first date at which a comment or activity was made to the bug by someone
+ other than the user who created the issue
+ """
+ message_dates = [message['date_created'] for message in item['messages_data']
+ if item['owner_data'].get('name', None) != message['owner_data'].get('name', None)]
+ activity_dates = [activity['datechanged'] for activity in item['activity_data']
+ if item['owner_data'].get('name', None) != activity['person_data'].get('name', None)]
+ activity_dates.extend(message_dates)
+ if activity_dates:
+ return min(activity_dates)
+ return None
diff --git a/grimoire_elk/raw/launchpad.py b/grimoire_elk/raw/launchpad.py
index a393730ae..daa0f73e4 100644
--- a/grimoire_elk/raw/launchpad.py
+++ b/grimoire_elk/raw/launchpad.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2015-2019 Bitergia
+# Copyright (C) 2015-2020 Bitergia
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,13 +16,52 @@
# along with this program. If not, see .
#
# Authors:
-# Valerio Cosentino
+# Nitish Gupta
#
from .elastic import ElasticOcean
+from ..elastic_mapping import Mapping as BaseMapping
+
+
+class Mapping(BaseMapping):
+
+ @staticmethod
+ def get_elastic_mappings(es_major):
+ """Get Elasticsearch mapping.
+
+ :param es_major: major version of Elasticsearch, as string
+ :returns: dictionary with a key, 'items', with the mapping
+ """
+
+ mapping = '''
+ {
+ "dynamic":true,
+ "properties": {
+ "data": {
+ "dynamic":false,
+ "properties": {}
+ }
+ }
+ }
+ '''
+
+ return {"items": mapping}
class LaunchpadOcean(ElasticOcean):
"""Launchpad Ocean feeder"""
- pass
+ mapping = Mapping
+
+ @classmethod
+ def get_perceval_params_from_url(cls, url):
+ params = []
+ splits = url.split('/')
+ if '+source' in url:
+ params.append(splits[-3])
+ params.append('--package')
+ params.append(splits[-1])
+ else:
+ params.append(splits[-1])
+
+ return params
diff --git a/grimoire_elk/utils.py b/grimoire_elk/utils.py
index cde7d87b3..09c314453 100755
--- a/grimoire_elk/utils.py
+++ b/grimoire_elk/utils.py
@@ -53,6 +53,7 @@
from perceval.backends.core.hyperkitty import HyperKitty, HyperKittyCommand
from perceval.backends.core.jenkins import Jenkins, JenkinsCommand
from perceval.backends.core.jira import Jira, JiraCommand
+from perceval.backends.core.launchpad import Launchpad, LaunchpadCommand
from perceval.backends.core.mattermost import Mattermost, MattermostCommand
from perceval.backends.core.mbox import MBox, MBoxCommand
from perceval.backends.core.mediawiki import MediaWiki, MediaWikiCommand
@@ -101,6 +102,7 @@
from .enriched.jenkins import JenkinsEnrich
from .enriched.jira import JiraEnrich
from .enriched.kitsune import KitsuneEnrich
+from .enriched.launchpad import LaunchpadEnrich
from .enriched.mattermost import MattermostEnrich
from .enriched.mbox import MBoxEnrich
from .enriched.mediawiki import MediaWikiEnrich
@@ -142,6 +144,7 @@
from .raw.jenkins import JenkinsOcean
from .raw.jira import JiraOcean
from .raw.kitsune import KitsuneOcean
+from .raw.launchpad import LaunchpadOcean
from .raw.mattermost import MattermostOcean
from .raw.mbox import MBoxOcean
from .raw.mediawiki import MediaWikiOcean
@@ -242,6 +245,7 @@ def get_connectors():
"jenkins": [Jenkins, JenkinsOcean, JenkinsEnrich, JenkinsCommand],
"jira": [Jira, JiraOcean, JiraEnrich, JiraCommand],
"kitsune": [Kitsune, KitsuneOcean, KitsuneEnrich, KitsuneCommand],
+ "launchpad": [Launchpad, LaunchpadOcean, LaunchpadEnrich, LaunchpadCommand],
"mattermost": [Mattermost, MattermostOcean, MattermostEnrich, MattermostCommand],
"mbox": [MBox, MBoxOcean, MBoxEnrich, MBoxCommand],
"mediawiki": [MediaWiki, MediaWikiOcean, MediaWikiEnrich, MediaWikiCommand],
diff --git a/releases/unreleased/add-support-for-launchpad.yml b/releases/unreleased/add-support-for-launchpad.yml
new file mode 100644
index 000000000..e006dd7bb
--- /dev/null
+++ b/releases/unreleased/add-support-for-launchpad.yml
@@ -0,0 +1,8 @@
+---
+title: Add support for Launchpad
+category: added
+author: Nitish Gupta
+issue: 842
+notes: Added support for creating raw and enriched
+ indexes of launchpad bugs. The schemas and
+ tests for data have also been added.
diff --git a/schema/launchpad.csv b/schema/launchpad.csv
new file mode 100644
index 000000000..101faa632
--- /dev/null
+++ b/schema/launchpad.csv
@@ -0,0 +1,87 @@
+name,type,aggregatable,description
+activity_count,long,true,"Count of activities on the bug. "
+assignee_data_bot,boolean,true,"True if the given assignee is identified as a bot."
+assignee_data_domain,keyword,true,"Assignee domain from Email. "
+assignee_data_gender,keyword,true,"Assignee gender. "
+assignee_gender_acc,long,true,"Assignee gender accuracy (disabled by default)."
+assignee_data_id,keyword,true,"Assignee Id from SortingHat."
+assignee_data_multi_org_names,keyword,true,"List of the assignee organizations from SortingHat profile."
+assignee_data_name,keyword,true,"Assignee name."
+assignee_data_org_name,keyword,true,"Assignee organization name from SortingHat profile."
+assignee_data_user_name,keyword,true,"Assignee username for the platform"
+assignee_data_uuid,keyword,true,"Assignee UUID from SortingHat."
+assignee_joined,date,true,"Date assignee joined the platform. "
+assignee_karma,long,true,"Assignee karma. "
+assignee_login,keyword,true,"Assignee username. "
+assignee_name,keyword,true,"Assignee real name. "
+assignee_time_zone,keyword,true,"Assignee region name. "
+author_bot,boolean,true,"True if the given author is identified as a bot."
+author_domain,keyword,true,"Author domain from Email. "
+author_gender,keyword,true,"Author gender. "
+author_gender_acc,long,true,"Author gender accuracy (disabled by default)."
+author_id,keyword,true,"Author Id from SortingHat."
+author_multi_org_names,keyword,true,"List of the assignee organizations from SortingHat profile."
+author_name,keyword,true,"Author name."
+author_org_name,keyword,true,"Author organization name from SortingHat profile."
+author_user_name,keyword,true,"Author username for the platform"
+author_uuid,keyword,true,"Author UUID from SortingHat."
+bug_id,keyword,true,"Bug ID on Launchpad. "
+bug_name,keyword,true,"Nickname for the bug. "
+bug_target_name,keyword,true,"Target of the bug. "
+date_created,date,true,"Date the bug was created. "
+date_incomplete,date,true,"Date the bug was marked incomplete. "
+date_last_updated,date,true,"Date the bug was last updated. "
+date_left_new,date,true,"Date the bug left status 'new'. "
+date_triaged,date,true,"Date the bug was marked Triaged. "
+description,keyword,false,"Description of the bug. "
+description_analyzed,text,false,"Description of bug split by terms to allow searching."
+grimoire_creation_date,date,true,"Message date (when the original author sent the message)."
+heat,long,true,"Heat(points) of the bug. "
+importance,keyword,true,"Importance of the bug. "
+is_complete,boolean,true,"1 if work on bug is completed, 0 if incomplete or ongoing. "
+is_launchpad_issue,boolean,true,"Is a launchpad bug."
+latest_patch_uploaded,date,true,"Date the last patch for bug was uploaded. "
+message_count,long,true,"Messages(comments) made on the bug. "
+metadata__enriched_on,date,true,"Date when the item was enriched."
+metadata__gelk_backend_name,keyword,true,"Name of the backend used to enrich information."
+metadata__gelk_version,keyword,true,"Version of the backend used to enrich information."
+metadata__timestamp,date,true,"Date when the item was stored in RAW index."
+metadata__updated_on,date,true,"Date when the item was updated in its original data source."
+origin,keyword,true,"Original URL where the room was retrieved from."
+owner_data_bot,boolean,true,"True if the given author is identified as a bot."
+owner_data_domain,keyword,true,"Owner domain from Email. "
+owner_data_gender,keyword,true,"Owner gender. "
+owner_data_gender_acc,long,true,"Owner gender accuracy (disabled by default)."
+owner_data_id,keyword,true,"Owner Id from SortingHat."
+owner_data_name,keyword,true,"Owner name."
+owner_data_org_name,keyword,true,"Owner organization name from SortingHat profile."
+owner_data_multi_org_names,keyword,true,"List of the assignee organizations from SortingHat profile."
+owner_data_user_name,keyword,true,"Owner username for the platform"
+owner_data_uuid,keyword,true,"Owner UUID from SortingHat."
+private,boolean,true,"True if bug is private. "
+project,keyword,true,"Project."
+project_1,keyword,true,"Project (if more than one level is allowed in project hierarchy)"
+reopened,boolean,true,"True if the bug was reopened. "
+security_related,boolean,true,"True if the bug is security related. "
+status,keyword,true,"Current status of the bug. "
+tag,keyword,true,"Perceval tag."
+tags,list,true,"Tags the bug was marked with. "
+time_assigned_to_closed,float,true,"Time difference from bug created to bug closed (in days). "
+time_created_to_assigned,date,true,"Time difference from bug created to bug assigned (in days). "
+time_open_days,float,true,"Time difference from bug created to bug closed for closed bugs, time created to now for open bugs(in days). """
+time_to_close_days,float,true,"Time difference from bug created to bug closed (in days). "
+time_to_confirm,float,true,"Time difference from bug created to bug confirmed (in days). "
+time_to_first_attention,float,true,"Time difference from bug created to first activity in bug (in days). "
+time_to_fix_commit,float,true,"Time difference from bug created to fix commit for the bug (in days). "
+time_to_last_update_days,float,true,"Time difference from bug last updated to now (in days). "
+time_worked_on,float,true,"Time difference from bug marked in progress to fix committed (in days). "
+time_created_to_last_update_days,float,true,"Time difference from bug creation to the most recent activity. "
+title,keyword,true,"Title of the bug. "
+user_joined,date,true,"Date the bug submitter joined the platform. "
+user_karma,long,true,"Bug submitter karma. "
+user_login,keyword,true,"Bug submitter username. "
+user_name,keyword,true,"Bug submitter real name. "
+user_time_zone,keyword,true,"Bug submitter region. "
+users_affected_count,long,true,"Count of users affected by the bug. "
+uuid,keyword,true,"Perceval UUID."
+web_link,keyword,true,"URL for the bug. "
\ No newline at end of file
diff --git a/tests/data/launchpad.json b/tests/data/launchpad.json
index 540015b20..352a44f8f 100644
--- a/tests/data/launchpad.json
+++ b/tests/data/launchpad.json
@@ -811,4 +811,319 @@
"timestamp": 1518165484.385153,
"updated_on": 1318885979.354332,
"uuid": "affb86ac0f679f9df3b4b345db330b2c3d7df49d"
-}]
\ No newline at end of file
+},{
+ "backend_name": "Launchpad",
+ "backend_version": "0.8.0",
+ "category": "issue",
+ "classified_fields_filtered": null,
+ "data": {
+ "activity_data": [],
+ "assignee_data": {
+ "admins_collection_link": "https://api.launchpad.net/1.0/~doko/admins",
+ "archive_link": "https://api.launchpad.net/1.0/~doko/+archive/ubuntu/ppa",
+ "confirmed_email_addresses_collection_link": "https://api.launchpad.net/1.0/~doko/confirmed_email_addresses",
+ "date_created": "2005-06-15T02:17:43.115113+00:00",
+ "deactivated_members_collection_link": "https://api.launchpad.net/1.0/~doko/deactivated_members",
+ "description": null,
+ "display_name": "Matthias Klose",
+ "expired_members_collection_link": "https://api.launchpad.net/1.0/~doko/expired_members",
+ "gpg_keys_collection_link": "https://api.launchpad.net/1.0/~doko/gpg_keys",
+ "hardware_submissions_collection_link": "https://api.launchpad.net/1.0/~doko/hardware_submissions",
+ "hide_email_addresses": false,
+ "homepage_content": null,
+ "http_etag": "\"a0b441a75b3f2856a6a373c7ec3507e35e0428d8-be1f4d53dc3befb7807949468b699938b1dde5b5\"",
+ "invited_members_collection_link": "https://api.launchpad.net/1.0/~doko/invited_members",
+ "irc_nicknames_collection_link": "https://api.launchpad.net/1.0/~doko/irc_nicknames",
+ "is_probationary": false,
+ "is_team": false,
+ "is_ubuntu_coc_signer": true,
+ "is_valid": true,
+ "jabber_ids_collection_link": "https://api.launchpad.net/1.0/~doko/jabber_ids",
+ "karma": 261688,
+ "languages_collection_link": "https://api.launchpad.net/1.0/~doko/languages",
+ "latitude": null,
+ "logo_link": "https://api.launchpad.net/1.0/~doko/logo",
+ "longitude": null,
+ "mailing_list_auto_subscribe_policy": "Ask me when I join a team",
+ "members_collection_link": "https://api.launchpad.net/1.0/~doko/members",
+ "members_details_collection_link": "https://api.launchpad.net/1.0/~doko/members_details",
+ "memberships_details_collection_link": "https://api.launchpad.net/1.0/~doko/memberships_details",
+ "mugshot_link": "https://api.launchpad.net/1.0/~doko/mugshot",
+ "name": "doko",
+ "open_membership_invitations_collection_link": "https://api.launchpad.net/1.0/~doko/open_membership_invitations",
+ "participants_collection_link": "https://api.launchpad.net/1.0/~doko/participants",
+ "ppas_collection_link": "https://api.launchpad.net/1.0/~doko/ppas",
+ "preferred_email_address_link": "tag:launchpad.net:2008:redacted",
+ "private": false,
+ "proposed_members_collection_link": "https://api.launchpad.net/1.0/~doko/proposed_members",
+ "recipes_collection_link": "https://api.launchpad.net/1.0/~doko/recipes",
+ "resource_type_link": "https://api.launchpad.net/1.0/#person",
+ "self_link": "https://api.launchpad.net/1.0/~doko",
+ "sshkeys_collection_link": "https://api.launchpad.net/1.0/~doko/sshkeys",
+ "sub_teams_collection_link": "https://api.launchpad.net/1.0/~doko/sub_teams",
+ "super_teams_collection_link": "https://api.launchpad.net/1.0/~doko/super_teams",
+ "team_owner_link": null,
+ "time_zone": "Europe/Berlin",
+ "visibility": "Public",
+ "web_link": "https://launchpad.net/~doko",
+ "wiki_names_collection_link": "https://api.launchpad.net/1.0/~doko/wiki_names"
+ },
+ "assignee_link": "https://api.launchpad.net/1.0/~doko",
+ "attachments_data": [],
+ "bug_data": {
+ "activity_collection_link": "https://api.launchpad.net/1.0/bugs/9560/activity",
+ "attachments_collection_link": "https://api.launchpad.net/1.0/bugs/9560/attachments",
+ "bug_tasks_collection_link": "https://api.launchpad.net/1.0/bugs/9560/bug_tasks",
+ "bug_watches_collection_link": "https://api.launchpad.net/1.0/bugs/9560/bug_watches",
+ "can_expire": false,
+ "cves_collection_link": "https://api.launchpad.net/1.0/bugs/9560/cves",
+ "date_created": "2004-10-28T20:45:27+00:00",
+ "date_last_message": "2004-10-28T20:45:27+00:00",
+ "date_last_updated": "2004-10-28T20:45:27+00:00",
+ "date_made_private": null,
+ "description": "The python-defaults package has been updated in Debian, and those changes\n need to be merged into Ubuntu. An automatic merge was\n attempted, but was not able to process all of the changes.\n\n The output from the automatic attempt can be found here:\n\n http://people.ubuntu.com/~scott/merge/review/python-defaults\n\n Some documentation about the output can be found here:\n\n http://people.ubuntu.com/~scott/merge/README",
+ "duplicate_of_link": null,
+ "duplicates_collection_link": "https://api.launchpad.net/1.0/bugs/9560/duplicates",
+ "heat": 6,
+ "http_etag": "\"67891235d53073572f1a03501d32bd8ff2fcfe6f-e109c31332b79b28fee5d7920d3ee4532c9f215a\"",
+ "id": 9560,
+ "information_type": "Public",
+ "latest_patch_uploaded": null,
+ "linked_branches_collection_link": "https://api.launchpad.net/1.0/bugs/9560/linked_branches",
+ "message_count": 2,
+ "messages_collection_link": "https://api.launchpad.net/1.0/bugs/9560/messages",
+ "name": null,
+ "number_of_duplicates": 0,
+ "other_users_affected_count_with_dupes": 0,
+ "owner_link": "https://api.launchpad.net/1.0/~debzilla",
+ "private": false,
+ "resource_type_link": "https://api.launchpad.net/1.0/#bug",
+ "security_related": false,
+ "self_link": "https://api.launchpad.net/1.0/bugs/9560",
+ "subscriptions_collection_link": "https://api.launchpad.net/1.0/bugs/9560/subscriptions",
+ "tags": [],
+ "title": "Unmerged changes from Debian",
+ "users_affected_collection_link": "https://api.launchpad.net/1.0/bugs/9560/users_affected",
+ "users_affected_count": 0,
+ "users_affected_count_with_dupes": 0,
+ "users_affected_with_dupes_collection_link": "https://api.launchpad.net/1.0/bugs/9560/users_affected_with_dupes",
+ "users_unaffected_collection_link": "https://api.launchpad.net/1.0/bugs/9560/users_unaffected",
+ "users_unaffected_count": 0,
+ "web_link": "https://bugs.launchpad.net/bugs/9560",
+ "who_made_private_link": null
+ },
+ "bug_link": "https://api.launchpad.net/1.0/bugs/9560",
+ "bug_target_display_name": "python-defaults (Ubuntu)",
+ "bug_target_name": "python-defaults (Ubuntu)",
+ "bug_watch_link": null,
+ "date_assigned": "2006-01-13T13:10:39.043735+00:00",
+ "date_closed": "2004-10-28T20:45:27+00:00",
+ "date_confirmed": null,
+ "date_created": "2004-10-28T20:45:27+00:00",
+ "date_fix_committed": null,
+ "date_fix_released": null,
+ "date_in_progress": null,
+ "date_incomplete": null,
+ "date_left_closed": null,
+ "date_left_new": null,
+ "date_triaged": null,
+ "http_etag": "\"7c39cd7d2e2c2fe4ea94fef7b99bc84232ad22e5-ae515ad55da1d844e4d7d555e04861948579efe0\"",
+ "importance": "Medium",
+ "is_complete": true,
+ "messages_data": [
+ {
+ "bug_attachments_collection_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults/+bug/9560/comments/0/bug_attachments",
+ "content": "The python-defaults package has been updated in Debian, and those changes\n need to be merged into Ubuntu. An automatic merge was\n attempted, but was not able to process all of the changes.\n\n The output from the automatic attempt can be found here:\n\n http://people.ubuntu.com/~scott/merge/review/python-defaults\n\n Some documentation about the output can be found here:\n\n http://people.ubuntu.com/~scott/merge/README",
+ "date_created": "2004-10-28T20:45:27+00:00",
+ "http_etag": "\"2e1c5dccf069da11648a9746a4f1f30ee2185fb6-f3891c6f4379b8539f2dca4201f5c4a7de24188f\"",
+ "owner_data": {
+ "admins_collection_link": "https://api.launchpad.net/1.0/~debzilla/admins",
+ "archive_link": null,
+ "confirmed_email_addresses_collection_link": "https://api.launchpad.net/1.0/~debzilla/confirmed_email_addresses",
+ "date_created": "2006-01-13T12:51:52.192089+00:00",
+ "deactivated_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/deactivated_members",
+ "description": null,
+ "display_name": "Debian Bug Importer",
+ "expired_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/expired_members",
+ "gpg_keys_collection_link": "https://api.launchpad.net/1.0/~debzilla/gpg_keys",
+ "hardware_submissions_collection_link": "https://api.launchpad.net/1.0/~debzilla/hardware_submissions",
+ "hide_email_addresses": false,
+ "homepage_content": null,
+ "http_etag": "\"501a3710aa3adcbeb1d1162a5b295b1d08442195-013b215ca9dbf0eee50601959f594495663aea7b\"",
+ "invited_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/invited_members",
+ "irc_nicknames_collection_link": "https://api.launchpad.net/1.0/~debzilla/irc_nicknames",
+ "is_probationary": true,
+ "is_team": false,
+ "is_ubuntu_coc_signer": false,
+ "is_valid": false,
+ "jabber_ids_collection_link": "https://api.launchpad.net/1.0/~debzilla/jabber_ids",
+ "karma": 0,
+ "languages_collection_link": "https://api.launchpad.net/1.0/~debzilla/languages",
+ "latitude": null,
+ "logo_link": "https://api.launchpad.net/1.0/~debzilla/logo",
+ "longitude": null,
+ "mailing_list_auto_subscribe_policy": "Ask me when I join a team",
+ "members_collection_link": "https://api.launchpad.net/1.0/~debzilla/members",
+ "members_details_collection_link": "https://api.launchpad.net/1.0/~debzilla/members_details",
+ "memberships_details_collection_link": "https://api.launchpad.net/1.0/~debzilla/memberships_details",
+ "mugshot_link": "https://api.launchpad.net/1.0/~debzilla/mugshot",
+ "name": "debzilla",
+ "open_membership_invitations_collection_link": "https://api.launchpad.net/1.0/~debzilla/open_membership_invitations",
+ "participants_collection_link": "https://api.launchpad.net/1.0/~debzilla/participants",
+ "ppas_collection_link": "https://api.launchpad.net/1.0/~debzilla/ppas",
+ "preferred_email_address_link": "tag:launchpad.net:2008:redacted",
+ "private": false,
+ "proposed_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/proposed_members",
+ "recipes_collection_link": "https://api.launchpad.net/1.0/~debzilla/recipes",
+ "resource_type_link": "https://api.launchpad.net/1.0/#person",
+ "self_link": "https://api.launchpad.net/1.0/~debzilla",
+ "sshkeys_collection_link": "https://api.launchpad.net/1.0/~debzilla/sshkeys",
+ "sub_teams_collection_link": "https://api.launchpad.net/1.0/~debzilla/sub_teams",
+ "super_teams_collection_link": "https://api.launchpad.net/1.0/~debzilla/super_teams",
+ "team_owner_link": null,
+ "time_zone": "UTC",
+ "visibility": "Public",
+ "web_link": "https://launchpad.net/~debzilla",
+ "wiki_names_collection_link": "https://api.launchpad.net/1.0/~debzilla/wiki_names"
+ },
+ "owner_link": "https://api.launchpad.net/1.0/~debzilla",
+ "parent_link": null,
+ "resource_type_link": "https://api.launchpad.net/1.0/#message",
+ "self_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults/+bug/9560/comments/0",
+ "subject": "Unmerged changes from Debian",
+ "web_link": "https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/9560/comments/0"
+ },
+ {
+ "bug_attachments_collection_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults/+bug/9560/comments/1/bug_attachments",
+ "content": "synced from unstable\n",
+ "date_created": "2004-11-10T23:45:07+00:00",
+ "http_etag": "\"4713c1a3617ba3e6f5e037bcaae2545d89b20351-6d421b8cad97cbe08fe9b711db716e3089b004d0\"",
+ "owner_data": {
+ "admins_collection_link": "https://api.launchpad.net/1.0/~doko/admins",
+ "archive_link": "https://api.launchpad.net/1.0/~doko/+archive/ubuntu/ppa",
+ "confirmed_email_addresses_collection_link": "https://api.launchpad.net/1.0/~doko/confirmed_email_addresses",
+ "date_created": "2005-06-15T02:17:43.115113+00:00",
+ "deactivated_members_collection_link": "https://api.launchpad.net/1.0/~doko/deactivated_members",
+ "description": null,
+ "display_name": "Matthias Klose",
+ "expired_members_collection_link": "https://api.launchpad.net/1.0/~doko/expired_members",
+ "gpg_keys_collection_link": "https://api.launchpad.net/1.0/~doko/gpg_keys",
+ "hardware_submissions_collection_link": "https://api.launchpad.net/1.0/~doko/hardware_submissions",
+ "hide_email_addresses": false,
+ "homepage_content": null,
+ "http_etag": "\"a0b441a75b3f2856a6a373c7ec3507e35e0428d8-be1f4d53dc3befb7807949468b699938b1dde5b5\"",
+ "invited_members_collection_link": "https://api.launchpad.net/1.0/~doko/invited_members",
+ "irc_nicknames_collection_link": "https://api.launchpad.net/1.0/~doko/irc_nicknames",
+ "is_probationary": false,
+ "is_team": false,
+ "is_ubuntu_coc_signer": true,
+ "is_valid": true,
+ "jabber_ids_collection_link": "https://api.launchpad.net/1.0/~doko/jabber_ids",
+ "karma": 261688,
+ "languages_collection_link": "https://api.launchpad.net/1.0/~doko/languages",
+ "latitude": null,
+ "logo_link": "https://api.launchpad.net/1.0/~doko/logo",
+ "longitude": null,
+ "mailing_list_auto_subscribe_policy": "Ask me when I join a team",
+ "members_collection_link": "https://api.launchpad.net/1.0/~doko/members",
+ "members_details_collection_link": "https://api.launchpad.net/1.0/~doko/members_details",
+ "memberships_details_collection_link": "https://api.launchpad.net/1.0/~doko/memberships_details",
+ "mugshot_link": "https://api.launchpad.net/1.0/~doko/mugshot",
+ "name": "doko",
+ "open_membership_invitations_collection_link": "https://api.launchpad.net/1.0/~doko/open_membership_invitations",
+ "participants_collection_link": "https://api.launchpad.net/1.0/~doko/participants",
+ "ppas_collection_link": "https://api.launchpad.net/1.0/~doko/ppas",
+ "preferred_email_address_link": "tag:launchpad.net:2008:redacted",
+ "private": false,
+ "proposed_members_collection_link": "https://api.launchpad.net/1.0/~doko/proposed_members",
+ "recipes_collection_link": "https://api.launchpad.net/1.0/~doko/recipes",
+ "resource_type_link": "https://api.launchpad.net/1.0/#person",
+ "self_link": "https://api.launchpad.net/1.0/~doko",
+ "sshkeys_collection_link": "https://api.launchpad.net/1.0/~doko/sshkeys",
+ "sub_teams_collection_link": "https://api.launchpad.net/1.0/~doko/sub_teams",
+ "super_teams_collection_link": "https://api.launchpad.net/1.0/~doko/super_teams",
+ "team_owner_link": null,
+ "time_zone": "Europe/Berlin",
+ "visibility": "Public",
+ "web_link": "https://launchpad.net/~doko",
+ "wiki_names_collection_link": "https://api.launchpad.net/1.0/~doko/wiki_names"
+ },
+ "owner_link": "https://api.launchpad.net/1.0/~doko",
+ "parent_link": null,
+ "resource_type_link": "https://api.launchpad.net/1.0/#message",
+ "self_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults/+bug/9560/comments/1",
+ "subject": "Re: Unmerged changes from Debian",
+ "web_link": "https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/9560/comments/1"
+ }
+ ],
+ "milestone_link": null,
+ "owner_data": {
+ "admins_collection_link": "https://api.launchpad.net/1.0/~debzilla/admins",
+ "archive_link": null,
+ "confirmed_email_addresses_collection_link": "https://api.launchpad.net/1.0/~debzilla/confirmed_email_addresses",
+ "date_created": "2006-01-13T12:51:52.192089+00:00",
+ "deactivated_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/deactivated_members",
+ "description": null,
+ "display_name": "Debian Bug Importer",
+ "expired_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/expired_members",
+ "gpg_keys_collection_link": "https://api.launchpad.net/1.0/~debzilla/gpg_keys",
+ "hardware_submissions_collection_link": "https://api.launchpad.net/1.0/~debzilla/hardware_submissions",
+ "hide_email_addresses": false,
+ "homepage_content": null,
+ "http_etag": "\"501a3710aa3adcbeb1d1162a5b295b1d08442195-013b215ca9dbf0eee50601959f594495663aea7b\"",
+ "invited_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/invited_members",
+ "irc_nicknames_collection_link": "https://api.launchpad.net/1.0/~debzilla/irc_nicknames",
+ "is_probationary": true,
+ "is_team": false,
+ "is_ubuntu_coc_signer": false,
+ "is_valid": false,
+ "jabber_ids_collection_link": "https://api.launchpad.net/1.0/~debzilla/jabber_ids",
+ "karma": 0,
+ "languages_collection_link": "https://api.launchpad.net/1.0/~debzilla/languages",
+ "latitude": null,
+ "logo_link": "https://api.launchpad.net/1.0/~debzilla/logo",
+ "longitude": null,
+ "mailing_list_auto_subscribe_policy": "Ask me when I join a team",
+ "members_collection_link": "https://api.launchpad.net/1.0/~debzilla/members",
+ "members_details_collection_link": "https://api.launchpad.net/1.0/~debzilla/members_details",
+ "memberships_details_collection_link": "https://api.launchpad.net/1.0/~debzilla/memberships_details",
+ "mugshot_link": "https://api.launchpad.net/1.0/~debzilla/mugshot",
+ "name": "debzilla",
+ "open_membership_invitations_collection_link": "https://api.launchpad.net/1.0/~debzilla/open_membership_invitations",
+ "participants_collection_link": "https://api.launchpad.net/1.0/~debzilla/participants",
+ "ppas_collection_link": "https://api.launchpad.net/1.0/~debzilla/ppas",
+ "preferred_email_address_link": "tag:launchpad.net:2008:redacted",
+ "private": false,
+ "proposed_members_collection_link": "https://api.launchpad.net/1.0/~debzilla/proposed_members",
+ "recipes_collection_link": "https://api.launchpad.net/1.0/~debzilla/recipes",
+ "resource_type_link": "https://api.launchpad.net/1.0/#person",
+ "self_link": "https://api.launchpad.net/1.0/~debzilla",
+ "sshkeys_collection_link": "https://api.launchpad.net/1.0/~debzilla/sshkeys",
+ "sub_teams_collection_link": "https://api.launchpad.net/1.0/~debzilla/sub_teams",
+ "super_teams_collection_link": "https://api.launchpad.net/1.0/~debzilla/super_teams",
+ "team_owner_link": null,
+ "time_zone": "UTC",
+ "visibility": "Public",
+ "web_link": "https://launchpad.net/~debzilla",
+ "wiki_names_collection_link": "https://api.launchpad.net/1.0/~debzilla/wiki_names"
+ },
+ "owner_link": "https://api.launchpad.net/1.0/~debzilla",
+ "related_tasks_collection_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults/+bug/9560/related_tasks",
+ "resource_type_link": "https://api.launchpad.net/1.0/#bug_task",
+ "self_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults/+bug/9560",
+ "status": "Fix Released",
+ "target_link": "https://api.launchpad.net/1.0/ubuntu/+source/python-defaults",
+ "title": "Bug #9560 in python-defaults (Ubuntu): \"Unmerged changes from Debian\"",
+ "web_link": "https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/9560"
+ },
+ "origin": "https://launchpad.net/ubuntu/+source/python-defaults",
+ "perceval_version": "0.13.0",
+ "search_fields": {
+ "distribution": "ubuntu/+source/python-defaults",
+ "item_id": "9560"
+ },
+ "tag": "https://launchpad.net/ubuntu/+source/python-defaults",
+ "timestamp": 1587919219.875151,
+ "updated_on": 1098996327.0,
+ "uuid": "252bb297c901a660f8a9752997840a6882bbd2f2"
+}]
diff --git a/tests/data/projects-release.json b/tests/data/projects-release.json
index d9a805c95..197eb5ed0 100644
--- a/tests/data/projects-release.json
+++ b/tests/data/projects-release.json
@@ -63,6 +63,9 @@
"https://jira.opnfv.org --filter-raw=data.fields.project.key:PROJECT-KEY"
],
"kitsune": [""],
+ "launchpad": [
+ "https://launchpad.net/ubuntu"
+ ],
"mattermost": [
"https://chat.openshift.io 8j366ft5affy3p36987pcugaoa"
],
diff --git a/tests/test_launchpad.py b/tests/test_launchpad.py
new file mode 100644
index 000000000..f7841f0a4
--- /dev/null
+++ b/tests/test_launchpad.py
@@ -0,0 +1,318 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2015-2019 Bitergia
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+# Authors:
+# Nitish Gupta
+#
+import logging
+import unittest
+
+import requests
+from base import TestBaseBackend
+from grimoire_elk.raw.launchpad import LaunchpadOcean
+
+
+class TestLaunchpad(TestBaseBackend):
+ """Test Launchpad backend"""
+
+ connector = "launchpad"
+ ocean_index = "test_" + connector
+ enrich_index = "test_" + connector + "_enrich"
+
+ def test_has_identities(self):
+ """Test value of has_identities method"""
+
+ enrich_backend = self.connectors[self.connector][2]()
+ self.assertTrue(enrich_backend.has_identities())
+
+ def test_items_to_raw(self):
+ """Test whether JSON items are properly inserted into ES"""
+
+ result = self._test_items_to_raw()
+
+ self.assertEqual(result['items'], 4)
+ self.assertEqual(result['raw'], 4)
+
+ def test_raw_to_enrich(self):
+ """Test whether the raw index is properly enriched"""
+
+ result = self._test_raw_to_enrich()
+ self.assertEqual(result['raw'], 4)
+ self.assertEqual(result['enrich'], 4)
+
+ enrich_backend = self.connectors[self.connector][2]()
+
+ item = self.items[0]
+ eitem = enrich_backend.get_rich_item(item)
+ self.assertEqual(eitem['offset'], None)
+ self.assertEqual(eitem['origin'], 'https://launchpad.net/mydistribution')
+ self.assertEqual(eitem['tag'], 'https://launchpad.net/mydistribution')
+ self.assertEqual(eitem['uuid'], 'db64288a362e6c086d344bed242fd5914f966e29')
+ self.assertIn('title', eitem)
+ self.assertEqual(eitem['web_link'], 'https://bugs.launchpad.net/mydistribution/+source/mypackage/+bug/1')
+ self.assertEqual(eitem['date_created'], '2017-08-21T14:28:00.336698+00:00')
+ self.assertEqual(eitem['date_incomplete'], None)
+ self.assertEqual(eitem['is_complete'], False)
+ self.assertEqual(eitem['status'], 'Triaged')
+ self.assertEqual(eitem['bug_target_name'], 'synaptic (Ubuntu)')
+ self.assertEqual(eitem['importance'], 'High')
+ self.assertEqual(eitem['date_triaged'], '2017-08-21T14:50:35.930044+00:00')
+ self.assertEqual(eitem['date_left_new'], '2017-08-21T14:50:35.930044+00:00')
+ self.assertEqual(eitem['time_to_last_update_days'], 0.0)
+ self.assertEqual(eitem['reopened'], 0)
+ self.assertEqual(eitem['time_to_fix_commit'], None)
+ self.assertEqual(eitem['time_worked_on'], None)
+ self.assertEqual(eitem['time_to_confirm'], 0.02)
+ self.assertEqual(eitem['user_login'], 'user')
+ self.assertEqual(eitem['user_name'], 'Cristian Aravena Romero')
+ self.assertEqual(eitem['user_joined'], '2005-06-15T02:17:43.115113+00:00')
+ self.assertEqual(eitem['user_karma'], 1841)
+ self.assertEqual(eitem['user_time_zone'], 'America/Santiago')
+ self.assertEqual(eitem['assignee_login'], 'user')
+ self.assertEqual(eitem['assignee_name'], 'Cristian Aravena Romero')
+ self.assertEqual(eitem['assignee_joined'], '2005-06-15T02:17:43.115113+00:00')
+ self.assertEqual(eitem['assignee_karma'], 1841)
+ self.assertEqual(eitem['assignee_time_zone'], 'America/Santiago')
+ self.assertEqual(eitem['bug_name'], None)
+ self.assertEqual(eitem['bug_id'], 1)
+ self.assertEqual(eitem['latest_patch_uploaded'], None)
+ self.assertEqual(eitem['security_related'], False)
+ self.assertEqual(eitem['private'], False)
+ self.assertEqual(eitem['users_affected_count'], 3)
+ self.assertIn('description', eitem)
+ self.assertEqual(eitem['tags'], [])
+ self.assertEqual(eitem['date_last_updated'], '2011-10-17T21:12:59.354332+00:00')
+ self.assertEqual(eitem['message_count'], 2)
+ self.assertEqual(eitem['heat'], 22)
+ self.assertEqual(eitem['time_to_first_attention'], None)
+ self.assertEqual(eitem['activity_count'], 1)
+ self.assertEqual(eitem['is_launchpad_issue'], 1)
+ self.assertEqual(eitem['time_created_to_last_update_days'], 2041.07)
+
+ item = self.items[1]
+ eitem = enrich_backend.get_rich_item(item)
+ self.assertEqual(eitem['offset'], None)
+ self.assertEqual(eitem['origin'], 'https://launchpad.net/mydistribution')
+ self.assertEqual(eitem['tag'], 'https://launchpad.net/mydistribution')
+ self.assertEqual(eitem['uuid'], 'c99e2f572749ea280b7f05cd5ea78d39bcd17a00')
+ self.assertIn('title', eitem)
+ self.assertEqual(eitem['web_link'], 'https://bugs.launchpad.net/mydistribution/+source/mypackage/+bug/2')
+ self.assertEqual(eitem['date_created'], '2006-03-16T19:25:37.186986+00:00')
+ self.assertEqual(eitem['date_incomplete'], None)
+ self.assertEqual(eitem['is_complete'], False)
+ self.assertEqual(eitem['status'], 'Confirmed')
+ self.assertEqual(eitem['bug_target_name'], 'synaptic (Ubuntu)')
+ self.assertEqual(eitem['importance'], 'Medium')
+ self.assertEqual(eitem['date_triaged'], None)
+ self.assertEqual(eitem['date_left_new'], '2010-11-01T00:30:06.794525+00:00')
+ self.assertEqual(eitem['time_to_last_update_days'], 4175.79)
+ self.assertEqual(eitem['reopened'], 1)
+ self.assertEqual(eitem['time_to_fix_commit'], None)
+ self.assertEqual(eitem['time_worked_on'], None)
+ self.assertEqual(eitem['time_to_confirm'], 1690.21)
+ self.assertEqual(eitem['user_login'], 'user')
+ self.assertEqual(eitem['user_name'], 'Cristian Aravena Romero')
+ self.assertEqual(eitem['user_joined'], '2005-06-15T02:17:43.115113+00:00')
+ self.assertEqual(eitem['user_karma'], 1841)
+ self.assertEqual(eitem['user_time_zone'], 'America/Santiago')
+ self.assertEqual(eitem['bug_name'], None)
+ self.assertEqual(eitem['bug_id'], 2)
+ self.assertEqual(eitem['latest_patch_uploaded'], None)
+ self.assertEqual(eitem['security_related'], False)
+ self.assertEqual(eitem['private'], False)
+ self.assertEqual(eitem['users_affected_count'], 6)
+ self.assertEqual(eitem['description'], 'Posting here what gnome says ')
+ self.assertEqual(eitem['tags'], ['amd64', 'apport-bug', 'artful', 'wayland', 'wayland-session'])
+ self.assertEqual(eitem['date_last_updated'], '2017-09-16T01:57:40.183918+00:00')
+ self.assertEqual(eitem['message_count'], 14)
+ self.assertEqual(eitem['heat'], 120)
+ self.assertEqual(eitem['time_to_first_attention'], None)
+ self.assertEqual(eitem['activity_count'], 1)
+ self.assertEqual(eitem['is_launchpad_issue'], 1)
+ self.assertEqual(eitem['time_created_to_last_update_days'], 25.48)
+
+ item = self.items[2]
+ eitem = enrich_backend.get_rich_item(item)
+ self.assertEqual(eitem['offset'], None)
+ self.assertEqual(eitem['origin'], 'https://launchpad.net/mydistribution')
+ self.assertEqual(eitem['tag'], 'https://launchpad.net/mydistribution')
+ self.assertEqual(eitem['uuid'], 'affb86ac0f679f9df3b4b345db330b2c3d7df49d')
+ self.assertIn('title', eitem)
+ self.assertEqual(eitem['web_link'], 'https://bugs.launchpad.net/mydistribution/+source/mypackage/+bug/3')
+ self.assertEqual(eitem['date_created'], '2006-07-28T09:10:11.023558+00:00')
+ self.assertEqual(eitem['date_incomplete'], None)
+ self.assertEqual(eitem['is_complete'], False)
+ self.assertEqual(eitem['status'], 'Confirmed')
+ self.assertEqual(eitem['bug_target_name'], 'synaptic (Ubuntu)')
+ self.assertEqual(eitem['importance'], 'Medium')
+ self.assertEqual(eitem['date_triaged'], None)
+ self.assertEqual(eitem['date_left_new'], None)
+ self.assertEqual(eitem['reopened'], 1)
+ self.assertEqual(eitem['time_to_fix_commit'], None)
+ self.assertEqual(eitem['time_worked_on'], None)
+ self.assertEqual(eitem['time_to_confirm'], 1681.92)
+ self.assertEqual(eitem['user_login'], 'user')
+ self.assertEqual(eitem['user_name'], 'Cristian Aravena Romero')
+ self.assertEqual(eitem['user_joined'], '2005-06-15T02:17:43.115113+00:00')
+ self.assertEqual(eitem['user_karma'], 1841)
+ self.assertEqual(eitem['user_time_zone'], 'America/Santiago')
+ self.assertEqual(eitem['bug_name'], None)
+ self.assertEqual(eitem['bug_id'], 3)
+ self.assertEqual(eitem['latest_patch_uploaded'], None)
+ self.assertEqual(eitem['security_related'], False)
+ self.assertEqual(eitem['private'], False)
+ self.assertEqual(eitem['users_affected_count'], 3)
+ self.assertEqual(eitem['tags'], [])
+ self.assertEqual(eitem['date_last_updated'], '2011-10-17T21:12:59.354332+00:00')
+ self.assertEqual(eitem['message_count'], 13)
+ self.assertEqual(eitem['heat'], 22)
+ self.assertEqual(eitem['time_to_first_attention'], None)
+ self.assertEqual(eitem['activity_count'], 0)
+ self.assertEqual(eitem['is_launchpad_issue'], 1)
+ self.assertEqual(eitem['time_created_to_last_update_days'], 2041.07)
+
+ item = self.items[3]
+ eitem = enrich_backend.get_rich_item(item)
+ self.assertEqual(eitem['offset'], None)
+ self.assertEqual(eitem['origin'], 'https://launchpad.net/ubuntu/+source/python-defaults')
+ self.assertEqual(eitem['tag'], 'https://launchpad.net/ubuntu/+source/python-defaults')
+ self.assertEqual(eitem['uuid'], '252bb297c901a660f8a9752997840a6882bbd2f2')
+ self.assertIn('title', eitem)
+ self.assertEqual(eitem['web_link'], 'https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/9560')
+ self.assertEqual(eitem['date_created'], '2004-10-28T20:45:27+00:00')
+ self.assertEqual(eitem['date_incomplete'], None)
+ self.assertEqual(eitem['is_complete'], True)
+ self.assertEqual(eitem['status'], 'Fix Released')
+ self.assertEqual(eitem['bug_target_name'], 'python-defaults (Ubuntu)')
+ self.assertEqual(eitem['importance'], 'Medium')
+ self.assertEqual(eitem['date_triaged'], None)
+ self.assertEqual(eitem['date_left_new'], None)
+ self.assertEqual(eitem['time_to_close_days'], 0.0)
+ self.assertEqual(eitem['reopened'], 0)
+ self.assertEqual(eitem['time_to_fix_commit'], None)
+ self.assertEqual(eitem['time_worked_on'], None)
+ self.assertEqual(eitem['time_to_confirm'], None)
+ self.assertEqual(eitem['user_login'], 'debzilla')
+ self.assertEqual(eitem['user_name'], 'Debian Bug Importer')
+ self.assertEqual(eitem['user_joined'], '2006-01-13T12:51:52.192089+00:00')
+ self.assertEqual(eitem['user_karma'], 0)
+ self.assertEqual(eitem['user_time_zone'], 'UTC')
+ self.assertEqual(eitem['assignee_login'], 'doko')
+ self.assertEqual(eitem['assignee_name'], 'Matthias Klose')
+ self.assertEqual(eitem['assignee_joined'], '2005-06-15T02:17:43.115113+00:00')
+ self.assertEqual(eitem['assignee_karma'], 261688)
+ self.assertEqual(eitem['assignee_time_zone'], 'Europe/Berlin')
+ self.assertEqual(eitem['bug_name'], None)
+ self.assertEqual(eitem['bug_id'], 9560)
+ self.assertEqual(eitem['latest_patch_uploaded'], None)
+ self.assertEqual(eitem['security_related'], False)
+ self.assertEqual(eitem['private'], False)
+ self.assertEqual(eitem['users_affected_count'], 0)
+ self.assertIn('description', eitem)
+ self.assertEqual(eitem['tags'], [])
+ self.assertEqual(eitem['date_last_updated'], '2004-10-28T20:45:27+00:00')
+ self.assertEqual(eitem['message_count'], 2)
+ self.assertEqual(eitem['heat'], 6)
+ self.assertEqual(eitem['time_to_first_attention'], 13.12)
+ self.assertEqual(eitem['activity_count'], 0)
+ self.assertEqual(eitem['is_launchpad_issue'], 1)
+ self.assertEqual(eitem['time_created_to_last_update_days'], 0.0)
+
+ def test_raw_to_enrich_sorting_hat(self):
+ """Test enrich with SortingHat"""
+
+ result = self._test_raw_to_enrich(sortinghat=True)
+ self.assertEqual(result['raw'], 4)
+ self.assertEqual(result['enrich'], 4)
+
+ enrich_backend = self.connectors[self.connector][2]()
+ enrich_backend.sortinghat = True
+
+ url = self.es_con + "/" + self.enrich_index + "/_search"
+ response = enrich_backend.requests.get(url, verify=False).json()
+ for hit in response['hits']['hits']:
+ source = hit['_source']
+ if 'author_uuid' in source:
+ self.assertIn('author_domain', source)
+ self.assertIn('author_gender', source)
+ self.assertIn('author_gender_acc', source)
+ self.assertIn('author_org_name', source)
+ self.assertIn('author_bot', source)
+ self.assertIn('author_name', source)
+ self.assertIn('author_multi_org_names', source)
+ self.assertIn('owner_data_gender', source)
+ self.assertIn('owner_data_gender_acc', source)
+ self.assertIn('owner_data_multi_org_names', source)
+ self.assertIn('owner_data_name', source)
+ self.assertIn('owner_data_user_name', source)
+ self.assertIn('owner_data_uuid', source)
+
+ def test_raw_to_enrich_projects(self):
+ """Test enrich with Projects"""
+
+ result = self._test_raw_to_enrich(projects=True)
+ self.assertEqual(result['raw'], 4)
+ self.assertEqual(result['enrich'], 4)
+
+ res = requests.get(self.es_con + "/" + self.enrich_index + "/_search", verify=False)
+ for eitem in res.json()['hits']['hits']:
+ self.assertEqual(eitem['_source']['project'], "Main")
+
+ def test_perceval_params(self):
+ """Test the extraction of perceval params from an URL"""
+
+ url1 = "https://launchpad.net/ubuntu/+source/python-defaults"
+ url2 = "https://launchpad.net/launchpad"
+ expected_params = [
+ ['ubuntu', '--package', 'python-defaults'],
+ ['launchpad']
+ ]
+ self.assertListEqual(LaunchpadOcean.get_perceval_params_from_url(url1), expected_params[0])
+ self.assertListEqual(LaunchpadOcean.get_perceval_params_from_url(url2), expected_params[1])
+
+ def test_copy_raw_fields(self):
+ """Test copied raw fields"""
+
+ self._test_raw_to_enrich()
+ enrich_backend = self.connectors[self.connector][2]()
+
+ for item in self.items:
+ eitem = enrich_backend.get_rich_item(item)
+ for attribute in enrich_backend.RAW_FIELDS_COPY:
+ if attribute in item:
+ self.assertEqual(item[attribute], eitem[attribute])
+ else:
+ self.assertIsNone(eitem[attribute])
+
+ def test_refresh_identities(self):
+ """Test refresh identities"""
+
+ result = self._test_refresh_identities()
+ # ... ?
+
+ def test_refresh_project(self):
+ """Test refresh project field for all sources"""
+
+ result = self._test_refresh_project()
+ # ... ?
+
+
+if __name__ == "__main__":
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
+ logging.getLogger("urllib3").setLevel(logging.WARNING)
+ logging.getLogger("requests").setLevel(logging.WARNING)
+ unittest.main(warnings='ignore')