def test_getWaitingConnections(self):
        allowed_device_len = random.randint(1, 10)
        # First we add valid elements to the self.connections
        for i in range(allowed_device_len):

            kwargs = {}
            kwargs['screen'] = mock.MagicMock()
            kwargs['connections'] = self.connections
            kwargs['device'] = mock.MagicMock()
            kwargs['username'] = config.username
            kwargs['password'] = config.password
            kwargs['device'].name = 'device1'
            kwargs['start_time'] = time.time()
            kwargs['all_diffs'] = 'abc'
            kwargs['diff_fh'] = 'abc'

            jnx = push.JunoscriptRpc(**kwargs)
            jnx.fsm = main.FSM_PushJnx(init_state=main.FSM_PushJnx.ST_START)

            jnx.device = mock.MagicMock()
            jnx.device.vendor = mock.MagicMock()
            jnx.device.vendor.name = 'juniper'

            allowed_states = [jnx.fsm.ST_WAIT_FOR_CONFIRM, jnx.fsm.ST_ROLLBACK,
                              jnx.fsm.ST_ROLLBACK_TESTING,
                              jnx.fsm.ST_ROLLBACK_COMMIT,
                              jnx.fsm.ST_ROLLBACK_COMMIT_TESTING]

            curr_allowed_state = random.randint(1, 5) - 1

            jnx.fsm.state = allowed_states[curr_allowed_state]
            self.connections.append(copy.deepcopy(jnx))

        # Introducing an element with invalid state to the list
        jnx.fsm.state = 1000
        self.connections.append(copy.deepcopy(jnx))

        valid_list = self.screen.getWaitingConnections()

        # Since the last element of self.connections is invalid
        # the valid_list must be equal to self.connections[:-1]
        self.assertEqual(valid_list, self.connections[:-1])
This tests the getWaitingConnections method.
dataset/ETHPy150Open facebook/fbpush/tests/test_push.py/FBPushScreenTestCase.test_getWaitingConnections