Пример #1
0
    def setUp(self):
        """Injects several system runs and import attempts to the database
        before every test. New progress logs will be linked to these entities.
        """
        client = utils.create_test_datastore_client()
        self.resource = progress_log_list.ProgressLogList(client)
        run_list_resource = system_run_list.SystemRunList(client)
        attempt_list_resource = import_attempt_list.ImportAttemptList(client)

        runs = [{
            _RUN.branch_name: 'test-branch',
            _RUN.pr_number: 0
        }, {
            _RUN.branch_name: 'prod-branch',
            _RUN.pr_number: 1
        }]
        self.runs = utils.ingest_system_runs(run_list_resource, runs)

        # Linked to the first run
        attempts = [
            {
                _ATTEMPT.import_name: 'cpi-u'
            },
            {
                _ATTEMPT.import_name: 'cpi-w'
            },
        ]
        self.attempts = utils.ingest_import_attempts(run_list_resource,
                                                     attempt_list_resource,
                                                     attempts,
                                                     system_run=self.runs[0])
Пример #2
0
 def setUp(self):
     """Injects a system run and several import attempts to the database."""
     client = utils.create_test_datastore_client()
     self.resource = import_attempt.ImportAttemptByID(client)
     list_resource = import_attempt_list.ImportAttemptList(client)
     run_list_resource = system_run_list.SystemRunList(client)
     attempts = [{
         _ATTEMPT.provenance_url: 'google.com'
     }, {
         _ATTEMPT.provenance_url: 'facebook.com'
     }, {
         _ATTEMPT.provenance_url: 'bing.com'
     }]
     self.attempts = utils.ingest_import_attempts(run_list_resource,
                                                  list_resource, attempts)
Пример #3
0
    def setUp(self):
        """Injects a system run and several import attempts to the database."""
        client = utils.create_test_datastore_client()
        self.resource = import_attempt_list.ImportAttemptList(client)
        run_list_resource = system_run_list.SystemRunList(client)

        attempts = [{
            _ATTEMPT.import_name: 'cpi-u'
        }, {
            _ATTEMPT.import_name: 'cpi-w'
        }, {
            _ATTEMPT.import_name: 'cpi-w'
        }, {
            _ATTEMPT.import_name: 'c-cpi-u'
        }]
        self.attempts = utils.ingest_import_attempts(run_list_resource,
                                                     self.resource, attempts)
Пример #4
0
    def setUp(self):
        """Injects several system runs, import attempts, and progress logs
        to the database before every test.
        """
        client = utils.create_test_datastore_client()
        manager = utils.LogMessageManagerMock()
        self.by_log_id = progress_log.ProgressLogByID(client, manager)
        self.by_run_id = progress_log.ProgressLogByRunID(client, manager)
        self.by_attempt_id = progress_log.ProgressLogByAttemptID(
            client, manager)
        log_list_resource = progress_log_list.ProgressLogList(client, manager)
        run_list_resource = system_run_list.SystemRunList(client)
        attempt_list_resource = import_attempt_list.ImportAttemptList(client)

        runs = [{
            _RUN.branch_name: 'test-branch',
            _RUN.pr_number: 0
        }, {
            _RUN.branch_name: 'prod-branch',
            _RUN.pr_number: 1
        }]
        self.runs = utils.ingest_system_runs(run_list_resource, runs)

        # Linked to the first run
        attempts = [
            {
                _ATTEMPT.import_name: 'cpi-u'
            },
            {
                _ATTEMPT.import_name: 'cpi-w'
            },
        ]
        self.attempts = utils.ingest_import_attempts(run_list_resource,
                                                     attempt_list_resource,
                                                     attempts,
                                                     system_run=self.runs[0])

        self.logs = [
            # Linked to the first attempt
            {
                _LOG.level: 'info',
                _LOG.message: 'first',
                _LOG.attempt_id: self.attempts[0][_ATTEMPT.attempt_id]
            },
            # Linked to the first attempt and first run
            {
                _LOG.level: 'critical',
                _LOG.message: 'second',
                _LOG.attempt_id: self.attempts[0][_ATTEMPT.attempt_id],
                _LOG.run_id: self.runs[0][_RUN.run_id]
            },
            # Linked to the first run
            {
                _LOG.level: 'debug',
                _LOG.message: 'third',
                _LOG.run_id: self.runs[0][_RUN.run_id]
            }
        ]
        with mock.patch(utils.PARSE_ARGS) as parse_args:
            parse_args.side_effect = self.logs
            for i, _ in enumerate(self.logs):
                self.logs[i] = log_list_resource.post()