class GearsSkeletonTest(unittest.TestCase):

    def setUp(self):
        self.config = Config().parse("valid_config.json")
        self.ariane_connector = ArianeConnector(self.config)

    def test_gear_skeleton(self):
        if self.ariane_connector.ready:
            system_gear = SystemGear.start(config=self.config).proxy()
            time.sleep(100)

            directory_update_count = system_gear.directory_gear.get().update_count.get()
            self.assertTrue(directory_update_count >= 1)

            mapping_update_count = system_gear.mapping_gear.get().update_count.get()
            self.assertTrue(mapping_update_count >= 1)

            current_blob = system_gear.component.get().component_cache_actor.get().blob.get()
            self.assertTrue(current_blob is not None)

            system_gear.stop()
            system_gear = SystemGear.start(config=self.config).proxy()
            time.sleep(100)

            current_blob = system_gear.component.get().component_cache_actor.get().blob.get()
            self.assertTrue(current_blob is not None)
            system_gear.stop()

            self.ariane_connector.stop()

    def tearDown(self):
        self.ariane_connector.stop()
 def test_start_and_stop_with_no_gears(self):
     ariane_connector = ArianeConnector(self.config)
     injector_ui_procos_entity_id = ariane_connector.injector_ui_procos_entity.id
     self.assertIsNotNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id))
     ariane_connector.stop()
     test_injector_service = InjectorService(self.rbmq_args)
     self.assertIsNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id))
     test_injector_service.stop()
    def test_start_and_stop_with_one_gear(self):
        ariane_connector = ArianeConnector(self.config)
        injector_ui_procos_entity_id = ariane_connector.injector_ui_procos_entity.id
        self.assertIsNotNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id))

        gear = InjectorGearSkeleton.start(gear_id='ariane.community.plugin.procos.gears.cache.localhost',
                                          gear_name='procos@localhost',
                                          gear_description='Ariane remote injector for localhost',
                                          gear_admin_queue='ariane.community.plugin.procos.gears.cache.localhost',
                                          running=False).proxy()
        self.assertTrue(gear.cache(running=True).get())
        ariane_connector.stop()
        test_injector_service = InjectorService(self.rbmq_args)
        self.assertIsNotNone(InjectorUITreeService.find_ui_tree_entity(injector_ui_procos_entity_id))
        test_injector_service.stop()
 def setUp(self):
     self.config = Config().parse("valid_config.json")
     self.ariane_connector = ArianeConnector(self.config)