예제 #1
0
 def test_index_manager_get_indices_by_alias_with_duplicate(self):
     """
     Clean up the aliases when starting from a broken state: duplicate indices for an alias.
     """
     alias = "richie_courses"
     existing_indices = {
         "richie_courses_2013-05-04-03h12m33.123456s": {},
         "richie_courses_2014-05-04-03h12m33.123456s": {
             "aliases": {
                 "richie_courses": True
             }
         },
         "richie_courses_2015-05-04-03h12m33.123456s": {
             "aliases": {
                 "richie_courses": True
             }
         },
         "richie_organizations_2017-05-04-03h12m33.123456s": {
             "aliases": {
                 "richie_organizations": True
             }
         },
     }
     self.assertEqual(
         list(get_indices_by_alias(existing_indices, alias)),
         [
             ("richie_courses_2014-05-04-03h12m33.123456s",
              "richie_courses"),
             ("richie_courses_2015-05-04-03h12m33.123456s",
              "richie_courses"),
         ],
     )
예제 #2
0
 def test_index_manager_get_indices_by_alias_empty(self):
     """
     Don't wrongly push values when there is nothing to return.
     """
     alias = "richie_courses"
     existing_indices = {
         "richie_courses_2013-05-04-03h12m33.123456s": {},
         "richie_organizations_2017-05-04-03h12m33.123456s": {
             "aliases": {"richie_organizations": True}
         },
     }
     self.assertEqual(list(get_indices_by_alias(existing_indices, alias)), [])
예제 #3
0
 def test_index_manager_get_indices_by_alias(self):
     """
     Receive a generator that contains the n-1 index for an alias.
     """
     alias = "richie_courses"
     existing_indices = {
         "richie_courses_2014-05-04-03h12m33.123456s": {},
         "richie_courses_2015-05-04-03h12m33.123456s": {
             "aliases": {"richie_courses": True}
         },
         "richie_organizations_2017-05-04-03h12m33.123456s": {
             "aliases": {"richie_organizations": True}
         },
     }
     self.assertEqual(
         list(get_indices_by_alias(existing_indices, alias)),
         [("richie_courses_2015-05-04-03h12m33.123456s", "richie_courses")],
     )