def test_all_templates_are_rendered(self, render_mock): """ Tests that all templates specified in package.yml are rendered appropriately. """ from packager import main as packager_main pkgfile_content = ''' templates: Makefile.jinja: Makefile Test.jinja: Test ''' with patch('packager.open', mock_open(read_data=pkgfile_content), create=True): packager_main() empty_context = {'source': [], 'target': {}, 'tests': [], 'include_directories': ['dependencies/'] } render_mock.assert_any_call('Makefile.jinja', 'Makefile', empty_context) render_mock.assert_any_call('Test.jinja', 'Test', empty_context)
def test_unit_tests_template(self, render_mock): """ Tests that including tests in a package triggers the rendering of a CMakeLists.txt to build the unit tests. """ from packager import main as packager_main pkgfile_content = ''' tests: - pid_test.cpp ''' with patch('packager.open', mock_open(read_data=pkgfile_content), create=True): packager_main() expected_context = {'source': [], 'target': {}, 'tests': ['./pid_test.cpp'], 'include_directories': ['dependencies/'] } render_mock.assert_any_call('CMakeLists.txt.jinja', 'CMakeLists.txt', expected_context)