Skip to content

Commit

Permalink
DButils.addProcess: force empty output product to null (Closes #95)
Browse files Browse the repository at this point in the history
 * This fixes processes with no output product on postgresql.
  • Loading branch information
jtniehof authored and dnadeau-lanl committed Nov 22, 2021
1 parent 6469cb2 commit 4a8ec7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbprocessing/DButils.py
Expand Up @@ -902,7 +902,7 @@ def addProcess(self,
raise ValueError("output_timebase invalid choice")

p1 = self.Process()
p1.output_product = output_product
p1.output_product = Utils.toNone(output_product)
p1.process_name = process_name
p1.extra_params = Utils.toNone(extra_params)
p1.output_timebase = output_timebase
Expand Down
11 changes: 11 additions & 0 deletions unit_tests/test_DButils.py
Expand Up @@ -83,6 +83,17 @@ def test_addMissionOptionals(self):
self.assertEqual('/rootdir/errors', self.dbu.getErrorPath())
self.assertEqual('/rootdir', self.dbu.getInspectorDirectory())

def test_addProcessNoOutput(self):
"""Add a process with no output product"""
# This needs to be on "empty" db because our test non-empty
# doesn't allow null output product (old database)
pid = self.dbu.addProcess('no_output1', '', 'RUN')
self.assertIsNone(self.dbu.getEntry('Process', pid).output_product)
pid = self.dbu.addProcess('no_output2', None, 'RUN')
self.assertIsNone(self.dbu.getEntry('Process', pid).output_product)
pid = self.dbu.addProcess('no_output3', 0, 'RUN')
self.assertEqual(0, self.dbu.getEntry('Process', pid).output_product)


class DBUtilsOtherTests(TestSetup):
"""Tests that are not processqueue or get or add"""
Expand Down

0 comments on commit 4a8ec7a

Please sign in to comment.