def test_refresh_disabled(self):
        cluster = MockCluster()

        schema_event = {
            'change_type': 'CREATED',
            'keyspace': 'ks1',
            'table': 'table1'
        }

        status_event = {'change_type': 'UP', 'address': ('1.2.3.4', 9000)}

        topo_event = {
            'change_type': 'MOVED_NODE',
            'address': ('1.2.3.4', 9000)
        }

        cc_no_schema_refresh = ControlConnection(cluster, 1, -1, 0)
        cluster.scheduler.reset_mock()

        # no call on schema refresh
        cc_no_schema_refresh._handle_schema_change(schema_event)
        self.assertFalse(cluster.scheduler.schedule.called)
        self.assertFalse(cluster.scheduler.schedule_unique.called)

        # topo and status changes as normal
        cc_no_schema_refresh._handle_status_change(status_event)
        cc_no_schema_refresh._handle_topology_change(topo_event)
        cluster.scheduler.schedule_unique.assert_has_calls([
            call(ANY, cc_no_schema_refresh.refresh_node_list_and_token_map),
            call(ANY, cc_no_schema_refresh.refresh_node_list_and_token_map)
        ])

        cc_no_topo_refresh = ControlConnection(cluster, 1, 0, -1)
        cluster.scheduler.reset_mock()

        # no call on topo refresh
        cc_no_topo_refresh._handle_topology_change(topo_event)
        self.assertFalse(cluster.scheduler.schedule.called)
        self.assertFalse(cluster.scheduler.schedule_unique.called)

        # schema and status change refresh as normal
        cc_no_topo_refresh._handle_status_change(status_event)
        cc_no_topo_refresh._handle_schema_change(schema_event)
        cluster.scheduler.schedule_unique.assert_has_calls([
            call(ANY, cc_no_topo_refresh.refresh_node_list_and_token_map),
            call(0.0, cc_no_topo_refresh.refresh_schema,
                 schema_event['keyspace'], schema_event['table'], None, None,
                 None)
        ])
    def setUp(self):
        self.cluster = MockCluster()
        self.connection = MockConnection()
        self.time = FakeTime()

        self.control_connection = ControlConnection(self.cluster)
        self.control_connection._connection = self.connection
        self.control_connection._time = self.time
    def setUp(self):
        self.cluster = MockCluster()
        self.connection = MockConnection()
        self.time = FakeTime()

        # Use 2 for the schema_event_refresh_window which is what we would normally default to.
        self.control_connection = ControlConnection(self.cluster, 1, 2, 0)
        self.control_connection._connection = self.connection
        self.control_connection._time = self.time