Skip to content

Commit

Permalink
Moves no_output integration style test to main testing, replaces it w…
Browse files Browse the repository at this point in the history
…ith basic args check
  • Loading branch information
shidarin committed May 10, 2014
1 parent e4032e9 commit 71470d2
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions tests/test_cdl_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() ======================================================================

Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 71470d2

Please sign in to comment.