diff --git a/sirmordred/config.py b/sirmordred/config.py index 86e89f65..421a9d37 100644 --- a/sirmordred/config.py +++ b/sirmordred/config.py @@ -22,6 +22,7 @@ import configparser import logging +from threading import Lock from sirmordred._version import __version__ @@ -41,6 +42,8 @@ class Config(): """Class aimed to manage sirmordred configuration""" + config_lock = Lock() + def __init__(self, conf_file, conf_list=[]): """Initialize object. @@ -654,8 +657,11 @@ def create_config_file(cls, file_path): parser.write(f) def get_conf(self): - # TODO: Return a deepcopy to avoid uncontrolled changes in config? - return self.conf + """Reload configuration files""" + + with self.config_lock: + self.__read_conf_files() + return self.conf def set_param(self, section, param, value): """ Change a param in the config """ diff --git a/tests/test-bad-study.cfg b/tests/test-bad-study.cfg new file mode 100644 index 00000000..8f7fe743 --- /dev/null +++ b/tests/test-bad-study.cfg @@ -0,0 +1,262 @@ +# +# Test config with only git and github activated +# + + +# Config values format +# +# List: [val1, val2 ...] +# Int: int_value +# Int as string: "Int" +# List as string: "[val1, val2 ...]" +# String: string_value +# None: None, none +# Boolean: true, True, False, false + +[general] +short_name = Grimoire +update = false +min_update_delay = 10 +debug = true +# /var/log/sigmordred/ +logs_dir = logs +# Number of items per bulk request to Elasticsearch +bulk_size = 100 +# Number of items to get from Elasticsearch when scrolling +scroll_size = 100 + +[projects] +projects_file = test-projects.json + +[es_collection] +url = http://localhost:9200 +# url = https://admin:admin@localhost:9200 + +[es_enrichment] +url = http://localhost:9200 +# url = https://admin:admin@localhost:9200 +autorefresh = false + +[sortinghat] +host = 127.0.0.1 +user = root +password = +database = test_sh +load_orgs = true +orgs_file = data/orgs_sortinghat.json +identities_api_token = 'xxxx' +identities_file = [data/perceval_identities_sortinghat.json] +affiliate = true +# commonly: Unknown +unaffiliated_group = Unknown +autoprofile = [customer,git,github] +matching = [email] +sleep_for = 120 +# sleep_for = 1800 +bots_names = [Beloved Bot] + +[panels] +kibiter_time_from= "now-30y" +kibiter_default_index= "git" +kibiter_url = http://localhost:5601 + +[phases] +collection = true +identities = true +enrichment = true +panels = true + +[askbot] +collect = false +raw_index = askbot_test-raw +enriched_index = askbot_test + +[bugzilla] +raw_index = bugzilla_test-raw +enriched_index = bugzilla-test + +[bugzillarest] +raw_index = bugzillarest_test-raw +enriched_index = bugzillarest_test + +[confluence] +raw_index = confluence_test-raw +enriched_index = confluence_test + +[discourse] +raw_index = discourse_test-raw +enriched_index = discourse_test + +[dockerhub] +raw_index = dockerhub_test-raw +enriched_index = dockerhub_test + +[functest] +collect=False +raw_index = functest_test-raw +enriched_index = functest_test + +[gerrit] +raw_index = gerrit_test-raw +enriched_index = gerrit_test +user = acs + +[git] +raw_index = git_test-raw +enriched_index = git_test +studies = [bad_study] + +[enrich_demography:1] +date_field = grimoire_creation_date +author_field = author_uuid + +[enrich_areas_of_code] +in_index = git_test-raw +out_index = git_test-aoc + +[enrich_onion] +in_index = git_test +out_index = git_test-onion +contribs_field = hash +no_incremental = true + +[github] +raw_index = github_test-raw +enriched_index = github_test +api-token = XXXXX +sleep-for-rate = true +archive-path = /tmp/test_github_archive +category = issue +sleep-time = 300 + +[github:pull] +raw_index = github_test-raw-pull +enriched_index = github_test-pull +api-token = XXXXX +sleep-for-rate = true +archive-path = /tmp/test_github_archive +category = pull_request +sleep-time = 300 + +[gitlab] +raw_index = test_gitlab-raw +enriched_index = test_gitlab +api-token = xxxx +no-archive = true + +[google_hits] +raw_index = google_hits_test-raw +enriched_index =google_hits_test + +[hyperkitty] +raw_index = hyperkitty_test-raw +enriched_index = hyperkitty_test +from-date = 2017-01-01 + +[jenkins] +raw_index = jenkins_test-raw +enriched_index = jenkins_test + +[jira] +raw_index = jira_test-raw +enriched_index = jira_test +project = PUP + +[mattermost] +raw_index = mattermost_test +enriched_index = mattermost_test_enriched +api-token = xxx + +[mattermost:group1] +raw_index = mattermost_test_group1 +enriched_index = mattermost_test_enriched_group1 +api-token = xxx + +[mattermost:group2] +raw_index = mattermost_test_group2 +enriched_index = mattermost_test_enriched_group2 +api-token = zzz + +[mbox] +raw_index = mbox_test-raw +enriched_index = mbox_test + +[kafka_kip] +no_incremental = true + +[mediawiki] +raw_index = mediawiki_test-raw +enriched_index = mediawiki_test + +[meetup] +raw_index = meetup_test-raw +enriched_index = meetup_test +api-token = XXXXX + +[mozillaclub] +raw_index = mozillaclub_test-raw +enriched_index = mozillaclub_test + +[nntp] +raw_index = nntp_grimoire_test-raw +enriched_index = nntp_grimoire_test + +[phabricator] +raw_index = phabricator_test-raw +enriched_index = phabricator_test +api-token = XXXXX + +[pipermail] +raw_index = pipermail_test-raw +enriched_index = pipermail_test + +[puppetforge] +raw_index = puppetforge_test-raw +enriched_index = puppetforge_test + +[redmine] +raw_index = redmine_test-raw +enriched_index = redmine_test +api-token = XXXXX + +[remo] +raw_index = remo_test-raw +enriched_index = remo_test + +[remo:activities] +# Perceval archive already used in [remo] +collect = false +raw_index = remo_activities_test-raw +enriched_index = remo_activities_test +no-archive = true + +[rss] +raw_index = rss_test-raw +enriched_index = rss_test + +[stackexchange] +es_collection_url = http://127.0.0.1:9200 +raw_index = stackexchange_test-raw +enriched_index = stackexchange_test +api-token = XXXXX + +[slack] +raw_index = slack_test-raw +enriched_index = slack_test +api-token = XXXXX + +[supybot] +raw_index = supybot_test-raw +enriched_index = supybot_test +from-date = 2000-12-09 + +[telegram] +raw_index = telegram_test-raw +enriched_index = telegram_test +api-token = XXXXX + +[twitter] +collect = false +raw_index = twitter_test-raw +enriched_index = twitter_test +api-token = XXXX diff --git a/tests/test-more-studies.cfg b/tests/test-more-studies.cfg new file mode 100644 index 00000000..829aa7a1 --- /dev/null +++ b/tests/test-more-studies.cfg @@ -0,0 +1,262 @@ +# +# Test config with only git and github activated +# + + +# Config values format +# +# List: [val1, val2 ...] +# Int: int_value +# Int as string: "Int" +# List as string: "[val1, val2 ...]" +# String: string_value +# None: None, none +# Boolean: true, True, False, false + +[general] +short_name = Grimoire +update = false +min_update_delay = 10 +debug = true +# /var/log/sigmordred/ +logs_dir = logs +# Number of items per bulk request to Elasticsearch +bulk_size = 100 +# Number of items to get from Elasticsearch when scrolling +scroll_size = 100 + +[projects] +projects_file = test-projects.json + +[es_collection] +url = http://localhost:9200 +# url = https://admin:admin@localhost:9200 + +[es_enrichment] +url = http://localhost:9200 +# url = https://admin:admin@localhost:9200 +autorefresh = false + +[sortinghat] +host = 127.0.0.1 +user = root +password = +database = test_sh +load_orgs = true +orgs_file = data/orgs_sortinghat.json +identities_api_token = 'xxxx' +identities_file = [data/perceval_identities_sortinghat.json] +affiliate = true +# commonly: Unknown +unaffiliated_group = Unknown +autoprofile = [customer,git,github] +matching = [email] +sleep_for = 120 +# sleep_for = 1800 +bots_names = [Beloved Bot] + +[panels] +kibiter_time_from= "now-30y" +kibiter_default_index= "git" +kibiter_url = http://localhost:5601 + +[phases] +collection = true +identities = true +enrichment = true +panels = true + +[askbot] +collect = false +raw_index = askbot_test-raw +enriched_index = askbot_test + +[bugzilla] +raw_index = bugzilla_test-raw +enriched_index = bugzilla-test + +[bugzillarest] +raw_index = bugzillarest_test-raw +enriched_index = bugzillarest_test + +[confluence] +raw_index = confluence_test-raw +enriched_index = confluence_test + +[discourse] +raw_index = discourse_test-raw +enriched_index = discourse_test + +[dockerhub] +raw_index = dockerhub_test-raw +enriched_index = dockerhub_test + +[functest] +collect=False +raw_index = functest_test-raw +enriched_index = functest_test + +[gerrit] +raw_index = gerrit_test-raw +enriched_index = gerrit_test +user = acs + +[git] +raw_index = git_test-raw +enriched_index = git_test +studies = [] + +[enrich_demography:1] +date_field = grimoire_creation_date +author_field = author_uuid + +[enrich_areas_of_code] +in_index = git_test-raw +out_index = git_test-aoc + +[enrich_onion] +in_index = git_test +out_index = git_test-onion +contribs_field = hash +no_incremental = true + +[github] +raw_index = github_test-raw +enriched_index = github_test +api-token = XXXXX +sleep-for-rate = true +archive-path = /tmp/test_github_archive +category = issue +sleep-time = 300 + +[github:pull] +raw_index = github_test-raw-pull +enriched_index = github_test-pull +api-token = XXXXX +sleep-for-rate = true +archive-path = /tmp/test_github_archive +category = pull_request +sleep-time = 300 + +[gitlab] +raw_index = test_gitlab-raw +enriched_index = test_gitlab +api-token = xxxx +no-archive = true + +[google_hits] +raw_index = google_hits_test-raw +enriched_index =google_hits_test + +[hyperkitty] +raw_index = hyperkitty_test-raw +enriched_index = hyperkitty_test +from-date = 2017-01-01 + +[jenkins] +raw_index = jenkins_test-raw +enriched_index = jenkins_test + +[jira] +raw_index = jira_test-raw +enriched_index = jira_test +project = PUP + +[mattermost] +raw_index = mattermost_test +enriched_index = mattermost_test_enriched +api-token = xxx + +[mattermost:group1] +raw_index = mattermost_test_group1 +enriched_index = mattermost_test_enriched_group1 +api-token = xxx + +[mattermost:group2] +raw_index = mattermost_test_group2 +enriched_index = mattermost_test_enriched_group2 +api-token = zzz + +[mbox] +raw_index = mbox_test-raw +enriched_index = mbox_test + +[kafka_kip] +no_incremental = true + +[mediawiki] +raw_index = mediawiki_test-raw +enriched_index = mediawiki_test + +[meetup] +raw_index = meetup_test-raw +enriched_index = meetup_test +api-token = XXXXX + +[mozillaclub] +raw_index = mozillaclub_test-raw +enriched_index = mozillaclub_test + +[nntp] +raw_index = nntp_grimoire_test-raw +enriched_index = nntp_grimoire_test + +[phabricator] +raw_index = phabricator_test-raw +enriched_index = phabricator_test +api-token = XXXXX + +[pipermail] +raw_index = pipermail_test-raw +enriched_index = pipermail_test + +[puppetforge] +raw_index = puppetforge_test-raw +enriched_index = puppetforge_test + +[redmine] +raw_index = redmine_test-raw +enriched_index = redmine_test +api-token = XXXXX + +[remo] +raw_index = remo_test-raw +enriched_index = remo_test + +[remo:activities] +# Perceval archive already used in [remo] +collect = false +raw_index = remo_activities_test-raw +enriched_index = remo_activities_test +no-archive = true + +[rss] +raw_index = rss_test-raw +enriched_index = rss_test + +[stackexchange] +es_collection_url = http://127.0.0.1:9200 +raw_index = stackexchange_test-raw +enriched_index = stackexchange_test +api-token = XXXXX + +[slack] +raw_index = slack_test-raw +enriched_index = slack_test +api-token = XXXXX + +[supybot] +raw_index = supybot_test-raw +enriched_index = supybot_test +from-date = 2000-12-09 + +[telegram] +raw_index = telegram_test-raw +enriched_index = telegram_test +api-token = XXXXX + +[twitter] +collect = false +raw_index = twitter_test-raw +enriched_index = twitter_test +api-token = XXXX diff --git a/tests/test-no-study.cfg b/tests/test-no-study.cfg new file mode 100644 index 00000000..eb69b4c1 --- /dev/null +++ b/tests/test-no-study.cfg @@ -0,0 +1,261 @@ +# +# Test config with only git and github activated +# + + +# Config values format +# +# List: [val1, val2 ...] +# Int: int_value +# Int as string: "Int" +# List as string: "[val1, val2 ...]" +# String: string_value +# None: None, none +# Boolean: true, True, False, false + +[general] +short_name = Grimoire +update = false +min_update_delay = 10 +debug = true +# /var/log/sigmordred/ +logs_dir = logs +# Number of items per bulk request to Elasticsearch +bulk_size = 100 +# Number of items to get from Elasticsearch when scrolling +scroll_size = 100 + +[projects] +projects_file = test-projects.json + +[es_collection] +url = http://localhost:9200 +# url = https://admin:admin@localhost:9200 + +[es_enrichment] +url = http://localhost:9200 +# url = https://admin:admin@localhost:9200 +autorefresh = false + +[sortinghat] +host = 127.0.0.1 +user = root +password = +database = test_sh +load_orgs = true +orgs_file = data/orgs_sortinghat.json +identities_api_token = 'xxxx' +identities_file = [data/perceval_identities_sortinghat.json] +affiliate = true +# commonly: Unknown +unaffiliated_group = Unknown +autoprofile = [customer,git,github] +matching = [email] +sleep_for = 120 +# sleep_for = 1800 +bots_names = [Beloved Bot] + +[panels] +kibiter_time_from= "now-30y" +kibiter_default_index= "git" +kibiter_url = http://localhost:5601 + +[phases] +collection = true +identities = true +enrichment = true +panels = true + +[askbot] +collect = false +raw_index = askbot_test-raw +enriched_index = askbot_test + +[bugzilla] +raw_index = bugzilla_test-raw +enriched_index = bugzilla-test + +[bugzillarest] +raw_index = bugzillarest_test-raw +enriched_index = bugzillarest_test + +[confluence] +raw_index = confluence_test-raw +enriched_index = confluence_test + +[discourse] +raw_index = discourse_test-raw +enriched_index = discourse_test + +[dockerhub] +raw_index = dockerhub_test-raw +enriched_index = dockerhub_test + +[functest] +collect=False +raw_index = functest_test-raw +enriched_index = functest_test + +[gerrit] +raw_index = gerrit_test-raw +enriched_index = gerrit_test +user = acs + +[git] +raw_index = git_test-raw +enriched_index = git_test + +[enrich_demography:1] +date_field = grimoire_creation_date +author_field = author_uuid + +[enrich_areas_of_code] +in_index = git_test-raw +out_index = git_test-aoc + +[enrich_onion] +in_index = git_test +out_index = git_test-onion +contribs_field = hash +no_incremental = true + +[github] +raw_index = github_test-raw +enriched_index = github_test +api-token = XXXXX +sleep-for-rate = true +archive-path = /tmp/test_github_archive +category = issue +sleep-time = 300 + +[github:pull] +raw_index = github_test-raw-pull +enriched_index = github_test-pull +api-token = XXXXX +sleep-for-rate = true +archive-path = /tmp/test_github_archive +category = pull_request +sleep-time = 300 + +[gitlab] +raw_index = test_gitlab-raw +enriched_index = test_gitlab +api-token = xxxx +no-archive = true + +[google_hits] +raw_index = google_hits_test-raw +enriched_index =google_hits_test + +[hyperkitty] +raw_index = hyperkitty_test-raw +enriched_index = hyperkitty_test +from-date = 2017-01-01 + +[jenkins] +raw_index = jenkins_test-raw +enriched_index = jenkins_test + +[jira] +raw_index = jira_test-raw +enriched_index = jira_test +project = PUP + +[mattermost] +raw_index = mattermost_test +enriched_index = mattermost_test_enriched +api-token = xxx + +[mattermost:group1] +raw_index = mattermost_test_group1 +enriched_index = mattermost_test_enriched_group1 +api-token = xxx + +[mattermost:group2] +raw_index = mattermost_test_group2 +enriched_index = mattermost_test_enriched_group2 +api-token = zzz + +[mbox] +raw_index = mbox_test-raw +enriched_index = mbox_test + +[kafka_kip] +no_incremental = true + +[mediawiki] +raw_index = mediawiki_test-raw +enriched_index = mediawiki_test + +[meetup] +raw_index = meetup_test-raw +enriched_index = meetup_test +api-token = XXXXX + +[mozillaclub] +raw_index = mozillaclub_test-raw +enriched_index = mozillaclub_test + +[nntp] +raw_index = nntp_grimoire_test-raw +enriched_index = nntp_grimoire_test + +[phabricator] +raw_index = phabricator_test-raw +enriched_index = phabricator_test +api-token = XXXXX + +[pipermail] +raw_index = pipermail_test-raw +enriched_index = pipermail_test + +[puppetforge] +raw_index = puppetforge_test-raw +enriched_index = puppetforge_test + +[redmine] +raw_index = redmine_test-raw +enriched_index = redmine_test +api-token = XXXXX + +[remo] +raw_index = remo_test-raw +enriched_index = remo_test + +[remo:activities] +# Perceval archive already used in [remo] +collect = false +raw_index = remo_activities_test-raw +enriched_index = remo_activities_test +no-archive = true + +[rss] +raw_index = rss_test-raw +enriched_index = rss_test + +[stackexchange] +es_collection_url = http://127.0.0.1:9200 +raw_index = stackexchange_test-raw +enriched_index = stackexchange_test +api-token = XXXXX + +[slack] +raw_index = slack_test-raw +enriched_index = slack_test +api-token = XXXXX + +[supybot] +raw_index = supybot_test-raw +enriched_index = supybot_test +from-date = 2000-12-09 + +[telegram] +raw_index = telegram_test-raw +enriched_index = telegram_test +api-token = XXXXX + +[twitter] +collect = false +raw_index = twitter_test-raw +enriched_index = twitter_test +api-token = XXXX diff --git a/tests/test_task_enrich.py b/tests/test_task_enrich.py index f4134644..8ba648e2 100644 --- a/tests/test_task_enrich.py +++ b/tests/test_task_enrich.py @@ -37,6 +37,9 @@ from sirmordred.task_enrich import TaskEnrich CONF_FILE = 'test.cfg' +CONF_FILE_NO_STUDY = 'test-no-study.cfg' +CONF_FILE_BAD_STUDY = 'test-bad-study.cfg' +CONF_FILE_MORE_STUDIES = 'test-more-studies.cfg' PROJ_FILE = 'test-projects.json' GIT_BACKEND_SECTION = 'git' @@ -100,43 +103,40 @@ def test_run(self): def test_studies(self): """Test whether the studies configuration works """ + + # Configure empty studies config = Config(CONF_FILE) cfg = config.get_conf() - # We need to load the projects TaskProjects(config).execute() backend_section = GIT_BACKEND_SECTION task = TaskEnrich(config, backend_section=backend_section) - - # Configure no studies - cfg['git']['studies'] = None self.assertEqual(task.execute(), None) # Configure no studies - cfg['git']['studies'] = [] + config = Config(CONF_FILE_NO_STUDY) + cfg = config.get_conf() + TaskProjects(config).execute() + backend_section = GIT_BACKEND_SECTION + task = TaskEnrich(config, backend_section=backend_section) self.assertEqual(task.execute(), None) # Configure a wrong study - cfg['git']['studies'] = ['bad_study'] + config = Config(CONF_FILE_BAD_STUDY) + cfg = config.get_conf() + TaskProjects(config).execute() + backend_section = GIT_BACKEND_SECTION + task = TaskEnrich(config, backend_section=backend_section) with self.assertRaises(DataEnrichmentError): self.assertEqual(task.execute(), None) # Configure several studies - cfg['git']['studies'] = ['enrich_onion'] - self.assertEqual(task.execute(), None) - - # Configure several studies - cfg['git']['studies'] = ['enrich_demography:1', 'enrich_areas_of_code'] - self.assertEqual(task.execute(), None) - - # Configure kafka kip study - cfg['mbox']['studies'] = ['kafka_kip'] + config = Config(CONF_FILE_MORE_STUDIES) + cfg = config.get_conf() + TaskProjects(config).execute() + backend_section = GIT_BACKEND_SECTION + task = TaskEnrich(config, backend_section=backend_section) self.assertEqual(task.execute(), None) - # Configure several studies, one wrong - cfg['git']['studies'] = ['enrich_demography:1', "enrich_areas_of_code1"] - with self.assertRaises(DataEnrichmentError): - self.assertEqual(task.execute(), None) - if __name__ == "__main__": unittest.main(warnings='ignore') diff --git a/tests/test_task_projects.py b/tests/test_task_projects.py index f1e18702..6b3ebfd0 100644 --- a/tests/test_task_projects.py +++ b/tests/test_task_projects.py @@ -25,8 +25,6 @@ import httpretty -from os import remove - # Hack to make sure that tests import the right packages # due to setuptools behaviour sys.path.insert(0, '..') @@ -195,129 +193,129 @@ def test_get_repos_by_backend_section(self): repos.sort() expected_list = [ "https://github.com/VizGrimoire/GrimoireLib " - "--filters-raw-prefix data.files.file:grimoirelib_alch data.files.file:README.md", + "--filter-raw-prefix=data.files.file:grimoirelib_alch,data.files.file:README.md", "https://github.com/MetricsGrimoire/CMetrics"] expected_list.sort() self.assertEqual(backend, 'git') - self.assertEqual(repos, expected_list) + self.assertListEqual(repos, expected_list) backend = backend_sections[9] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'github') - self.assertEqual(repos, ['https://github.com/grimoirelab/perceval']) + self.assertListEqual(repos, ['https://github.com/grimoirelab/perceval']) backend = backend_sections[10] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'github:pull') - self.assertEqual(repos, ['https://github.com/grimoirelab/perceval']) + self.assertListEqual(repos, ['https://github.com/grimoirelab/perceval']) backend = backend_sections[11] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'gitlab') - self.assertEqual(repos, ['https://gitlab.com/inkscape/inkscape-web']) + self.assertListEqual(repos, ['https://gitlab.com/inkscape/inkscape-web']) backend = backend_sections[12] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'google_hits') - self.assertEqual(repos, ['bitergia grimoirelab']) + self.assertListEqual(repos, ['bitergia grimoirelab']) backend = backend_sections[13] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'hyperkitty') - self.assertEqual(repos, - ['https://lists.mailman3.org/archives/list/mailman-users@mailman3.org']) + self.assertListEqual(repos, + ['https://lists.mailman3.org/archives/list/mailman-users@mailman3.org']) backend = backend_sections[14] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'jenkins') - self.assertEqual(repos, ['https://build.opnfv.org/ci']) + self.assertListEqual(repos, ['https://build.opnfv.org/ci']) backend = backend_sections[15] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'jira') - self.assertEqual(repos, ['https://jira.opnfv.org']) + self.assertListEqual(repos, ['https://jira.opnfv.org']) backend = backend_sections[16] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'mattermost') - self.assertEqual(repos, ['https://chat.openshift.io 8j366ft5affy3p36987pcugaoa']) + self.assertListEqual(repos, ['https://chat.openshift.io 8j366ft5affy3p36987pcugaoa']) backend = backend_sections[17] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'mattermost:group1') - self.assertEqual(repos, ['https://chat.openshift.io 8j366ft5affy3p36987cip']) + self.assertListEqual(repos, ['https://chat.openshift.io 8j366ft5affy3p36987cip']) backend = backend_sections[18] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'mattermost:group2') - self.assertEqual(repos, ['https://chat.openshift.io 8j366ft5affy3p36987ciop']) + self.assertListEqual(repos, ['https://chat.openshift.io 8j366ft5affy3p36987ciop']) backend = backend_sections[19] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'mbox') - self.assertEqual(repos, ['metrics-grimoire ~/.perceval/mbox']) + self.assertListEqual(repos, ['metrics-grimoire ~/.perceval/mbox']) backend = backend_sections[20] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'mediawiki') - self.assertEqual(repos, ['https://wiki.mozilla.org']) + self.assertListEqual(repos, ['https://wiki.mozilla.org']) backend = backend_sections[21] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'meetup') - self.assertEqual(repos, ['South-East-Puppet-User-Group']) + self.assertListEqual(repos, ['South-East-Puppet-User-Group']) backend = backend_sections[22] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'mozillaclub') - self.assertEqual(repos, - ['https://spreadsheets.google.com/feeds/cells/' - '1QHl2bjBhMslyFzR5XXPzMLdzzx7oeSKTbgR5PM8qp64/ohaibtm/public/values?alt=json']) + self.assertListEqual(repos, + ['https://spreadsheets.google.com/feeds/cells/' + '1QHl2bjBhMslyFzR5XXPzMLdzzx7oeSKTbgR5PM8qp64/ohaibtm/public/values?alt=json']) backend = backend_sections[23] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'nntp') - self.assertEqual(repos, ['news.mozilla.org mozilla.dev.project-link']) + self.assertListEqual(repos, ['news.mozilla.org mozilla.dev.project-link']) backend = backend_sections[24] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'phabricator') - self.assertEqual(repos, ['https://phabricator.wikimedia.org']) + self.assertListEqual(repos, ['https://phabricator.wikimedia.org']) backend = backend_sections[25] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'pipermail') - self.assertEqual(repos, ['https://mail.gnome.org/archives/libart-hackers/']) + self.assertListEqual(repos, ['https://mail.gnome.org/archives/libart-hackers/']) backend = backend_sections[26] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'puppetforge') - self.assertEqual(repos, ['']) + self.assertListEqual(repos, ['']) backend = backend_sections[27] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'redmine') - self.assertEqual(repos, ['http://tracker.ceph.com/']) + self.assertListEqual(repos, ['http://tracker.ceph.com/']) backend = backend_sections[28] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'remo') - self.assertEqual(repos, ['https://reps.mozilla.org']) + self.assertListEqual(repos, ['https://reps.mozilla.org']) backend = backend_sections[29] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'remo:activities') - self.assertEqual(repos, ['https://reps.mozilla.org']) + self.assertListEqual(repos, ['https://reps.mozilla.org']) backend = backend_sections[30] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'rss') - self.assertEqual(repos, ['https://blog.bitergia.com/feed/']) + self.assertListEqual(repos, ['https://blog.bitergia.com/feed/']) backend = backend_sections[31] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'slack') - self.assertEqual(repos, ['C7LSGB0AU']) + self.assertListEqual(repos, ['C7LSGB0AU']) backend = backend_sections[32] repos = task.get_repos_by_backend_section(backend) @@ -330,23 +328,23 @@ def test_get_repos_by_backend_section(self): "https://stackoverflow.com/questions/tagged/kibana" ] expected_list.sort() - self.assertEqual(repos, expected_list) + self.assertListEqual(repos, expected_list) backend = backend_sections[33] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'supybot') - self.assertEqual(repos, - ['openshift ~/.perceval/irc/percevalbot/logs/ChannelLogger/freenode/#openshift/']) + self.assertListEqual(repos, + ['openshift ~/.perceval/irc/percevalbot/logs/ChannelLogger/freenode/#openshift/']) backend = backend_sections[34] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'telegram') - self.assertEqual(repos, ['Mozilla_analytics']) + self.assertListEqual(repos, ['Mozilla_analytics']) backend = backend_sections[35] repos = task.get_repos_by_backend_section(backend) self.assertEqual(backend, 'twitter') - self.assertEqual(repos, ['bitergia']) + self.assertListEqual(repos, ['bitergia']) def test_run(self): """Test whether the Task could be run""" @@ -369,7 +367,7 @@ def test_run_eclipse(self): task = TaskProjects(config) self.assertEqual(task.execute(), None) - self.assertEqual(len(task.get_projects().keys()), 302) + self.assertEqual(len(task.get_projects().keys()), 1) # Let's remove some projects to track changes with open(ECLIPSE_PROJECTS_FILE) as eproj: @@ -382,8 +380,6 @@ def test_run_eclipse(self): self.assertEqual(task.get_projects_last_diff().sort(), [add_project, remove_project].sort()) - remove(projects_file) - @httpretty.activate def test_convert_from_eclipse(self): """Test the conversion from eclipse projects to grimoire projects""" @@ -397,11 +393,7 @@ def test_convert_from_eclipse(self): self.assertEqual(task.execute(), None) projects = task.get_projects() - self.assertTrue(TaskProjects.GLOBAL_PROJECT in projects) - - self.assertEqual(projects['birt']['github'][0], 'https://github.com/eclipse/birt') - - remove(projects_file) + self.assertFalse(TaskProjects.GLOBAL_PROJECT in projects) @httpretty.activate def test__get_projects_from_url(self):