def test_insert_output(self):
        """An `uiapi.output` record is inserted correctly."""
        self.job = self.setup_classic_job()
        session = Session.get()
        output_path = self.generate_output_path(self.job)
        hmw = HazardMapDBWriter(session, output_path, self.job.id)

        # This job has no outputs before calling the function under test.
        self.assertEqual(0, len(self.job.output_set))

        # Call the function under test.
        hmw.insert_output()

        # After calling the function under test we see the expected output.
        self.assertEqual(1, len(self.job.output_set))

        # Make sure the inserted output record has the right data.
        [output] = self.job.output_set
        self.assertTrue(output.db_backed)
        self.assertEqual(output_path, output.path)
        self.assertEqual("hazard_map", output.output_type)
        self.assertIs(self.job, output.oq_job)
Esempio n. 2
0
    def test_insert_output(self):
        """An `uiapi.output` record is inserted correctly."""
        self.job = self.setup_classic_job()
        session = Session.get()
        output_path = self.generate_output_path(self.job)
        hmw = HazardMapDBWriter(session, output_path, self.job.id)

        # This job has no outputs before calling the function under test.
        self.assertEqual(0, len(self.job.output_set))

        # Call the function under test.
        hmw.insert_output()

        # After calling the function under test we see the expected output.
        self.assertEqual(1, len(self.job.output_set))

        # Make sure the inserted output record has the right data.
        [output] = self.job.output_set
        self.assertTrue(output.db_backed)
        self.assertEqual(output_path, output.path)
        self.assertEqual("hazard_map", output.output_type)
        self.assertIs(self.job, output.oq_job)