def test_apply_fixer_diff__no_intersection(self): strategy_factory = Mock() strategy = Mock() strategy_factory.return_value = strategy fixers.add_strategy('mock', strategy_factory) original = load_fixture('diff/no_intersect_original.txt') updated = load_fixture('diff/no_intersect_updated.txt') original = parse_diff(original) updated = parse_diff(updated) context = {'strategy': 'mock'} fixers.apply_fixer_diff(original, updated, context) self.assertEqual(0, strategy.execute.call_count)
def test_apply_fixer_diff__calls_execute(self): strategy_factory = Mock() strategy = Mock() strategy_factory.return_value = strategy fixers.add_strategy('mock', strategy_factory) original = load_fixture('diff/intersecting_hunks_original.txt') updated = load_fixture('diff/intersecting_hunks_updated.txt') original = parse_diff(original) updated = parse_diff(updated) context = {'strategy': 'mock'} fixers.apply_fixer_diff(original, updated, context) self.assertEqual(1, strategy.execute.call_count)
def test_apply_fixer_diff__no_intersection(): strategy_factory = Mock() strategy = Mock() strategy_factory.return_value = strategy fixers.add_strategy('mock', strategy_factory) original = load_fixture('diff/no_intersect_original.txt') updated = load_fixture('diff/no_intersect_updated.txt') original = parse_diff(original) updated = parse_diff(updated) context = {'strategy': 'mock'} fixers.apply_fixer_diff(original, updated, context) eq_(0, strategy.execute.call_count)
def test_apply_fixer_diff__strategy_execution_fails(): strategy_factory = Mock() strategy = Mock() strategy.execute.side_effect = RuntimeError strategy_factory.return_value = strategy fixers.add_strategy('mock', strategy_factory) original = load_fixture('diff/intersecting_hunks_original.txt') updated = load_fixture('diff/intersecting_hunks_updated.txt') original = parse_diff(original) updated = parse_diff(updated) context = {'strategy': 'mock'} out = fixers.apply_fixer_diff(original, updated, context) eq_(1, strategy.execute.call_count) eq_(out, None, 'No output and no exception')