@patch("nailgun.statistics.oswl.collector.time.sleep",
           side_effect=StopIteration)
    @patch.object(sys, "argv", new=["_", consts.OSWL_RESOURCE_TYPES.vm])
    def test_oswl_is_not_collected_when_stats_collecting_disabled(self, *_):
        collect_func_path = ("nailgun.statistics.oswl.collector.collect")
        must_send_stats_path = ("nailgun.statistics.oswl.collector"
                                ".MasterNodeSettings.must_send_stats")

        with patch(must_send_stats_path, return_value=False):
            with patch(collect_func_path) as collect_mock:
                try:
                    run_collecting()
                except __HOLE__:
                    pass

                self.assertFalse(collect_mock.called)

        with patch(must_send_stats_path, return_value=True):
            with patch(collect_func_path) as collect_mock:
                try:
                    run_collecting()
                except StopIteration:
                    pass

                self.assertTrue(collect_mock.called)
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/test/unit/fuel_statistics_tests/test_oswl_collector.py/TestOSWLCollector.test_oswl_is_not_collected_when_stats_collecting_disabled