def test_sync_from_rhic_serve_blocking(self): self.assertEqual(len(identity.JOBS), 0) rhics = ConsumerIdentity.objects() self.assertEquals(len(rhics), 0) sync_from_rhic_serve_blocking() rhics = ConsumerIdentity.objects() self.assertEquals(len(rhics), 3) expected_rhics = ["fb647f68-aa01-4171-b62b-35c2984a5328", "ef8548a9-c874-42a8-b5dc-bc5ab0b34cd7", "a17013d8-e896-4749-9b37-8606d62bf643"] for r in rhics: self.assertIn(str(r.uuid), expected_rhics)
def test_sync_where_existing_rhics_product_mapping_changes(self): self.assertEqual(len(identity.JOBS), 0) # Create a RHIC with products that will change after sync item = {} item["uuid"] = "fb647f68-aa01-4171-b62b-35c2984a5328" item["engineering_ids"] = ["1", "2"] create_or_update_consumer_identity(item) rhics = ConsumerIdentity.objects() self.assertEquals(len(rhics), 1) sync_from_rhic_serve_blocking() rhics = ConsumerIdentity.objects() self.assertEquals(len(rhics), 3) expected_rhics = ["fb647f68-aa01-4171-b62b-35c2984a5328", "ef8548a9-c874-42a8-b5dc-bc5ab0b34cd7", "a17013d8-e896-4749-9b37-8606d62bf643"] for r in rhics: self.assertIn(str(r.uuid), expected_rhics) # Ensure that the products have been updated rhic_under_test = ConsumerIdentity.objects(uuid=item["uuid"]).first() self.assertTrue(rhic_under_test) expected_products = ["183", "83", "69"] for ep in expected_products: self.assertTrue(ep in rhic_under_test.engineering_ids)
def sync_rhics(): """ Will synchronize RHIC to product mapping data from a RCS server. @return: status of synchronization, with optional error message: (True, "") - on success (False, "error message here") - on failure @rtype: (bool,str) """ start = time.time() _LOG.info("invoked") retval = identity.sync_from_rhic_serve_blocking() end = time.time() _LOG.info("finished in %s seconds" % (end-start)) return retval