'Test creating a zone.'

@mock.patch('libsoundtouch.device.SoundTouchDevice.create_zone')
@mock.patch('libsoundtouch.device.SoundTouchDevice.volume')
@mock.patch('libsoundtouch.device.SoundTouchDevice.status')
@mock.patch('libsoundtouch.soundtouch_device', side_effect=_mock_soundtouch_device)
def test_create_zone(self, mocked_sountouch_device, mocked_status, mocked_volume, mocked_create_zone):

    soundtouch.setup_platform(self.hass, default_component(), mock.MagicMock())
    soundtouch.setup_platform(self.hass, default_component(), mock.MagicMock())
    all_devices = self.hass.data[soundtouch.DATA_SOUNDTOUCH]
    all_devices[0].entity_id = 'media_player.entity_1'
    all_devices[1].entity_id = 'media_player.entity_2'
    self.assertEqual(mocked_sountouch_device.call_count, 2)
    self.assertEqual(mocked_status.call_count, 2)
    self.assertEqual(mocked_volume.call_count, 2)
    self.hass.services.call(soundtouch.DOMAIN, soundtouch.SERVICE_CREATE_ZONE, {'master': 'media_player.entity_1', 'slaves': ['media_player.entity_2']}, True)
    self.assertEqual(mocked_create_zone.call_count, 1)
    self.hass.services.call(soundtouch.DOMAIN, soundtouch.SERVICE_CREATE_ZONE, {'master': 'media_player.entity_X', 'slaves': ['media_player.entity_2']}, True)
    self.assertEqual(mocked_create_zone.call_count, 1)
    self.hass.services.call(soundtouch.DOMAIN, soundtouch.SERVICE_CREATE_ZONE, {'master': 'media_player.entity_X', 'slaves': []}, True)
    self.assertEqual(mocked_create_zone.call_count, 1)
