From 71470d2071a2ac2a49b8a9813d3c9314163b3200 Mon Sep 17 00:00:00 2001 From: Sean Wallitsch Date: Sat, 10 May 2014 00:06:20 -0700 Subject: [PATCH] Moves no_output integration style test to main testing, replaces it with basic args check --- tests/test_cdl_convert.py | 69 ++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/tests/test_cdl_convert.py b/tests/test_cdl_convert.py index 79fecb1..112d6ec 100644 --- a/tests/test_cdl_convert.py +++ b/tests/test_cdl_convert.py @@ -469,44 +469,16 @@ def testSanityCheck(self): #========================================================================== - @mock.patch('cdl_convert.cdl_convert.write_cc') - @mock.patch('cdl_convert.cdl_convert.parse_flex') - @mock.patch('os.path.abspath') - def testNoOutput(self, abspath, mockParse, mockWrite): - """Tests that we don't write a converted file""" - - abspath.return_value = 'file.flex' - cdl = cdl_convert.ColorCorrection( - id='uniqueId', cdl_file='file.flex' - ) + def testNoOutput(self): + """Tests that --no-output was picked up correctly""" - mockParse.return_value = [cdl, ] - sys.argv = ['scriptname', 'file.flex', '-o', 'cc', '--no-output'] + sys.argv = ['scriptname', 'inputFile', '--no-output'] - inputFormats = cdl_convert.INPUT_FORMATS - outputFormats = cdl_convert.OUTPUT_FORMATS - - mockInputs = dict(inputFormats) - mockInputs['flex'] = mockParse - cdl_convert.INPUT_FORMATS = mockInputs - - mockOutputs = dict(outputFormats) - mockOutputs['cc'] = mockWrite - cdl_convert.OUTPUT_FORMATS = mockOutputs - - cdl_convert.main() + args = cdl_convert.parse_args() - mockParse.assert_called_once_with('file.flex') - # Determine dest should have set a file_out - self.assertEqual( - 'uniqueId.cc', - cdl.file_out + self.assertTrue( + args.no_output ) - # But the write should never have been called. - mockWrite.assert_has_calls([]) - - cdl_convert.INPUT_FORMATS = inputFormats - cdl_convert.OUTPUT_FORMATS = outputFormats # main() ====================================================================== @@ -674,6 +646,35 @@ def testSanityCheckCalled(self, abspath, mockParse, mockWrite, mockSanity): #========================================================================== + @mock.patch('cdl_convert.cdl_convert.ColorCorrection.determine_dest') + @mock.patch('cdl_convert.cdl_convert.write_cc') + @mock.patch('cdl_convert.cdl_convert.parse_flex') + @mock.patch('os.path.abspath') + def testNoOutput(self, abspath, mockParse, mockWrite, mockDest): + """Tests that we don't write a converted file""" + + abspath.return_value = 'file.flex' + mockParse.return_value = [self.cdl, ] + sys.argv = ['scriptname', 'file.flex', '--no-output'] + + mockInputs = dict(self.inputFormats) + mockInputs['flex'] = mockParse + cdl_convert.INPUT_FORMATS = mockInputs + + mockOutputs = dict(self.outputFormats) + mockOutputs['cc'] = mockWrite + cdl_convert.OUTPUT_FORMATS = mockOutputs + + cdl_convert.main() + + mockParse.assert_called_once_with('file.flex') + # Determine dest should have set a file_out + mockDest.assert_called_once_with('cc') + # But the write should never have been called. + mockWrite.assert_has_calls([]) + + #========================================================================== + @mock.patch('cdl_convert.cdl_convert.write_cc') @mock.patch('cdl_convert.cdl_convert.parse_flex') @mock.patch('os.path.abspath')