Ejemplo n.º 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])
Ejemplo n.º 2
0
 def setUp(self):
     """Creates the endpoints before every test."""
     client = utils.create_test_datastore_client()
     # Used for querying system runs by run_id
     self.resource = system_run.SystemRunByID(client)
     # Used for creating system runs
     list_resource = system_run_list.SystemRunList(client)
     runs = [{}, {_MODEL.commit_sha: 'commit-sha'}]
     self.runs = utils.ingest_system_runs(list_resource, runs)
Ejemplo n.º 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.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)
Ejemplo n.º 4
0
 def setUp(self):
     """Injects several system runs to the database before every test."""
     self.resource = system_run_list.SystemRunList()
     runs = [{
         _MODEL.repo_name: 'dddd',
         _MODEL.pr_number: 0
     }, {
         _MODEL.repo_name: 'data',
         _MODEL.pr_number: 1
     }, {
         _MODEL.repo_name: 'data',
         _MODEL.pr_number: 3
     }, {
         _MODEL.repo_name: 'aaaa',
         _MODEL.pr_number: 2
     }]
     self.runs = utils.ingest_system_runs(self.resource, runs)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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()