def test_run_reprocessing_script_two_batches(self):
        # cronscripts/reprocess-hwdb-submissions.py begings to process
        # submissions with IDs starting at the value stored in the
        # file given as the parameter --start-file. When is has
        # finished processing the number of submissions specified by
        # --max-submissions, it stores the ID of the last prcessed
        # submission in start-file.
        new_submissions = []
        for count in range(5):
            new_submissions.append(
                self.factory.makeHWSubmission(
                    status=HWSubmissionProcessingStatus.INVALID))

        start_file_name = mktemp()
        start_file = open(start_file_name, 'w')
        start_file.write('%i' % new_submissions[1].id)
        start_file.close()
        transaction.commit()
        Store.of(new_submissions[0]).invalidate()

        retcode, stdout, stderr = run_script(
            'cronscripts/reprocess-hwdb-submissions.py',
            ['--max-submissions', '2', '--start-file', start_file_name])

        # We started with the ID of the second submission created abvoe,
        # so the first submission still has the status INVALID.
        self.assertEqual(HWSubmissionProcessingStatus.INVALID,
                         new_submissions[0].status)
        # We processed two submissions, they now have the status
        # PROCESSED.
        self.assertEqual(HWSubmissionProcessingStatus.PROCESSED,
                         new_submissions[1].status)
        self.assertEqual(HWSubmissionProcessingStatus.PROCESSED,
                         new_submissions[2].status)
        # The  following submissions were not yet touched,
        self.assertEqual(HWSubmissionProcessingStatus.INVALID,
                         new_submissions[3].status)
        self.assertEqual(HWSubmissionProcessingStatus.INVALID,
                         new_submissions[4].status)

        # The start file now contains the ID of the 4th submission.
        new_start = int(open(start_file_name).read())
        self.assertEqual(new_submissions[3].id, new_start)

        # When we run the script again, for only one submission,
        # the 4th submission is processed.
        transaction.abort()
        Store.of(new_submissions[0]).invalidate()
        retcode, stdout, stderr = run_script(
            'cronscripts/reprocess-hwdb-submissions.py',
            ['--max-submissions', '1', '--start-file', start_file_name])
        self.assertEqual(HWSubmissionProcessingStatus.PROCESSED,
                         new_submissions[3].status)
        self.assertEqual(HWSubmissionProcessingStatus.INVALID,
                         new_submissions[4].status)
 def test_run_reprocessing_script_no_params(self):
     # cronscripts/reprocess-hwdb-submissions.py needs at least the
     # parameter --start-file
     retcode, stdout, stderr = run_script(
         'cronscripts/reprocess-hwdb-submissions.py', [])
     self.assertThat(stderr, Contains('Option --start-file not specified.'))
     DatabaseLayer.force_dirty_database()
 def test_run_reprocessing_script_no_params(self):
     # cronscripts/reprocess-hwdb-submissions.py needs at least the
     # parameter --start-file
     retcode, stdout, stderr = run_script(
         'cronscripts/reprocess-hwdb-submissions.py', [])
     self.assertThat(
         stderr, Contains('Option --start-file not specified.'))
     DatabaseLayer.force_dirty_database()
Exemple #4
0
 def test_script(self):
     tempdir = self.makeTemporaryDirectory()
     workdir = self.makeTemporaryDirectory()
     (retval, out,
      err) = run_script(os.path.join(os.path.dirname(pottery.__file__),
                                     'generate_translation_templates.py'),
                        args=[tempdir, self.result_name, workdir])
     self.assertEqual(0, retval)
 def test_run_reprocessing_script_max_submission_not_integer(self):
     # If the parameter --max-submissions is not an integer,
     # cronscripts/reprocess-hwdb-submissions.py reports an error.
     retcode, stdout, stderr = run_script(
         'cronscripts/reprocess-hwdb-submissions.py',
         ['--max-submissions', 'nonsense'])
     expected = "Invalid value for --max_submissions specified: 'nonsense'"
     self.assertThat(stderr, Contains(expected))
     DatabaseLayer.force_dirty_database()
 def test_script(self):
     tempdir = self.makeTemporaryDirectory()
     workdir = self.makeTemporaryDirectory()
     (retval, out, err) = run_script(
         os.path.join(
             os.path.dirname(pottery.__file__),
             'generate_translation_templates.py'),
         args=[tempdir, self.result_name, workdir])
     self.assertEqual(0, retval)
 def test_run_reprocessing_script_startfile_does_not_exist(self):
     # If the specified start file does not exist,
     # cronscripts/reprocess-hwdb-submissions.py reports an error.
     does_not_exist = mktemp()
     retcode, stdout, stderr = run_script(
         'cronscripts/reprocess-hwdb-submissions.py',
         ['--start-file', does_not_exist])
     self.assertThat(
         stderr, Contains('Cannot access file %s' % does_not_exist))
     DatabaseLayer.force_dirty_database()
 def test_run_reprocessing_script_startfile_with_negative_integer(self):
     # If the specified start file contains any non-integer string,
     # cronscripts/reprocess-hwdb-submissions.py reports an error.
     start_file_name = mktemp()
     start_file = open(start_file_name, 'w')
     start_file.write('-1')
     start_file.close()
     retcode, stdout, stderr = run_script(
         'cronscripts/reprocess-hwdb-submissions.py',
         ['--start-file', start_file_name])
     self.assertThat(
         stderr,
         Contains('%s must contain a positive integer' % start_file_name))
     DatabaseLayer.force_dirty_database()
    def test_script(self):
        product = self.factory.makeProduct()
        self.factory.makeBug(target=product)
        self.assertEqual(0, get_bugsummary_rows(product).count())
        self.assertEqual(1, get_bugsummaryjournal_rows(product).count())
        transaction.commit()

        exit_code, out, err = run_script('scripts/bugsummary-rebuild.py')
        self.addDetail("stdout", text_content(out))
        self.addDetail("stderr", text_content(err))
        self.assertEqual(0, exit_code)

        transaction.commit()
        self.assertEqual(1, get_bugsummary_rows(product).count())
        self.assertEqual(0, get_bugsummaryjournal_rows(product).count())
    def test_run_reprocessing_script_two_batches(self):
        # cronscripts/reprocess-hwdb-submissions.py begings to process
        # submissions with IDs starting at the value stored in the
        # file given as the parameter --start-file. When is has
        # finished processing the number of submissions specified by
        # --max-submissions, it stores the ID of the last prcessed
        # submission in start-file.
        new_submissions = []
        for count in range(5):
            new_submissions.append(
                self.factory.makeHWSubmission(
                    status=HWSubmissionProcessingStatus.INVALID))

        start_file_name = mktemp()
        start_file = open(start_file_name, 'w')
        start_file.write('%i' % new_submissions[1].id)
        start_file.close()
        transaction.commit()
        Store.of(new_submissions[0]).invalidate()

        retcode, stdout, stderr = run_script(
            'cronscripts/reprocess-hwdb-submissions.py',
            ['--max-submissions', '2', '--start-file', start_file_name])

        # We started with the ID of the second submission created abvoe,
        # so the first submission still has the status INVALID.
        self.assertEqual(
            HWSubmissionProcessingStatus.INVALID,
            new_submissions[0].status)
        # We processed two submissions, they now have the status
        # PROCESSED.
        self.assertEqual(
            HWSubmissionProcessingStatus.PROCESSED,
            new_submissions[1].status)
        self.assertEqual(
            HWSubmissionProcessingStatus.PROCESSED,
            new_submissions[2].status)
        # The  following submissions were not yet touched,
        self.assertEqual(
            HWSubmissionProcessingStatus.INVALID,
            new_submissions[3].status)
        self.assertEqual(
            HWSubmissionProcessingStatus.INVALID,
            new_submissions[4].status)

        # The start file now contains the ID of the 4th submission.
        new_start = int(open(start_file_name).read())
        self.assertEqual(new_submissions[3].id, new_start)

        # When we run the script again, for only one submission,
        # the 4th submission is processed.
        transaction.abort()
        Store.of(new_submissions[0]).invalidate()
        retcode, stdout, stderr = run_script(
            'cronscripts/reprocess-hwdb-submissions.py',
            ['--max-submissions', '1', '--start-file', start_file_name])
        self.assertEqual(
            HWSubmissionProcessingStatus.PROCESSED,
            new_submissions[3].status)
        self.assertEqual(
            HWSubmissionProcessingStatus.INVALID,
            new_submissions[4].status)
Exemple #11
0
 def test_script(self):
     test_input = os.path.join(self._findTestData(), 'minimal.pot')
     script = 'scripts/rosetta/validate-translations-file.py'
     result, out, err = run_script(script, [test_input])
     self.assertEqual(0, result)
 def runScript(self):
     transaction.commit()
     (ret, out, err) = run_script('cronscripts/buildd-retry-depwait.py')
     self.assertEqual(0, ret)
     transaction.commit()
 def test_script(self):
     test_input = os.path.join(self._findTestData(), 'minimal.pot')
     script = 'scripts/rosetta/validate-translations-file.py'
     result, out, err = run_script(script, [test_input])
     self.assertEqual(0, result)
 def runScript(self):
     transaction.commit()
     (ret, out, err) = run_script('cronscripts/buildd-retry-depwait.py')
     self.assertEqual(0, ret)
     transaction.commit()