def test_start_platform_none_specified(self, mock_log, mock_process):
        """
        Test that both platforms run with no platform value is passed.
        """
        start_platforms(mock.ANY, mock.ANY)

        self.assertEqual(2, mock_process.call_count)
        self.assertEqual(4, mock_log.info.call_count)
    def test_start_platform_windows_specified(self, mock_log, mock_process):
        """
        Test that only windows platform runs.
        """
        start_platforms(mock.ANY, mock.ANY, platform=TestPlatform.windows)

        self.assertEqual(1, mock_process.call_count)
        self.assertEqual(2, mock_log.info.call_count)
        mock_log.info.assert_called_with("Windows VM process kicked off")
    def test_start_platform_linux_specified(self, mock_log, mock_process):
        """
        Test that only linux platform runs.
        """
        start_platforms(mock.ANY, mock.ANY, platform=TestPlatform.linux)

        self.assertEqual(1, mock_process.call_count)
        self.assertEqual(2, mock_log.info.call_count)
        mock_log.info.assert_called_with("Linux VM process kicked off")
Esempio n. 4
0
def cron(testing=False):
    """Script to run from cron for Sampleplatform."""
    from mod_ci.controllers import start_platforms, kvm_processor, TestPlatform
    from flask import current_app
    from run import config, log
    from database import create_session
    from github import GitHub

    log.info('Run the cron for kicking off CI platform(s).')
    # Create session
    db = create_session(config['DATABASE_URI'])
    gh = GitHub(access_token=config['GITHUB_TOKEN'])
    repository = gh.repos(config['GITHUB_OWNER'])(config['GITHUB_REPOSITORY'])

    if testing is True:
        kvm_processor(current_app._get_current_object(), db,
                      config.get('KVM_LINUX_NAME', ''), TestPlatform.linux,
                      repository, None)
    else:
        start_platforms(db, repository)