-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kitsune-demography' of 'https://github.com/jjmerchante/…
…grimoirelab-elk' Merges #1137 Closes #1137
- Loading branch information
Showing
3 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: Kitsune demography study | ||
category: added | ||
author: Jose Javier Merchante <[email protected]> | ||
issue: null | ||
notes: > | ||
Include demography study in Kitsune (SUMO). And update | ||
the index to include standard fields such as a unique | ||
identifier (`id`) and some missing fields like `origin` | ||
or `uuid`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,13 @@ | |
# Valerio Cosentino <[email protected]> | ||
# | ||
import logging | ||
import time | ||
import unittest | ||
|
||
from base import TestBaseBackend | ||
from grimoire_elk.enriched.utils import REPO_LABELS | ||
from grimoire_elk.enriched.enrich import (logger, | ||
anonymize_url) | ||
|
||
|
||
class TestKitsune(TestBaseBackend): | ||
|
@@ -111,6 +114,30 @@ def test_refresh_identities(self): | |
result = self._test_refresh_identities() | ||
# ... ? | ||
|
||
def test_demography_study(self): | ||
""" Test that the demography study works correctly """ | ||
|
||
alias = 'demographics' | ||
study, ocean_backend, enrich_backend = self._test_study('enrich_demography') | ||
|
||
with self.assertLogs(logger, level='INFO') as cm: | ||
if study.__name__ == "enrich_demography": | ||
study(ocean_backend, enrich_backend, alias) | ||
|
||
self.assertEqual(cm.output[0], 'INFO:grimoire_elk.enriched.enrich:[kitsune] Demography ' | ||
'starting study %s/test_kitsune_enrich' | ||
% anonymize_url(self.es_con)) | ||
self.assertEqual(cm.output[-1], 'INFO:grimoire_elk.enriched.enrich:[kitsune] Demography ' | ||
'end %s/test_kitsune_enrich' | ||
% anonymize_url(self.es_con)) | ||
|
||
time.sleep(5) # HACK: Wait until kitsune enrich index has been written | ||
items = [item for item in enrich_backend.fetch()] | ||
self.assertEqual(len(items), 9) | ||
for item in items: | ||
self.assertTrue('demography_min_date' in item.keys()) | ||
self.assertTrue('demography_max_date' in item.keys()) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') | ||
|