~tomasgroth/openlp/remote-sync

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core_api/test_websockets.py

  • Committer: Tomas Groth
  • Date: 2017-09-29 19:00:31 UTC
  • mfrom: (2733.1.39 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20170929190031-f3qecjkix27oxppo
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
        """
71
71
        # GIVEN: A new httpserver
72
72
        # WHEN: I start the server
73
 
        server = WebSocketServer()
 
73
        WebSocketServer()
74
74
 
75
75
        # THEN: the api environment should have been created
76
76
        self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
93
93
        """
94
94
        Test the poll function returns the correct JSON
95
95
        """
96
 
        # WHEN: the system is configured with a set of data
 
96
        # GIVEN: the system is configured with a set of data
97
97
        mocked_service_manager = MagicMock()
98
98
        mocked_service_manager.service_id = 21
99
99
        mocked_live_controller = MagicMock()
105
105
        mocked_live_controller.desktop_screen.isChecked.return_value = False
106
106
        Registry().register('live_controller', mocked_live_controller)
107
107
        Registry().register('service_manager', mocked_service_manager)
 
108
        # WHEN: The poller polls
 
109
        with patch.object(self.poll, 'is_stage_active') as mocked_is_stage_active, \
 
110
                patch.object(self.poll, 'is_live_active') as mocked_is_live_active, \
 
111
                patch.object(self.poll, 'is_chords_active') as mocked_is_chords_active:
 
112
            mocked_is_stage_active.return_value = True
 
113
            mocked_is_live_active.return_value = True
 
114
            mocked_is_chords_active.return_value = True
 
115
            poll_json = self.poll.poll()
108
116
        # THEN: the live json should be generated and match expected results
109
 
        poll_json = self.poll.poll()
110
117
        self.assertTrue(poll_json['results']['blank'], 'The blank return value should be True')
111
118
        self.assertFalse(poll_json['results']['theme'], 'The theme return value should be False')
112
119
        self.assertFalse(poll_json['results']['display'], 'The display return value should be False')