コード例 #1
0
ファイル: test_section.py プロジェクト: mproffitt/pyccata
 def test_section_render(self, mock_paragraph):
     Config = namedtuple('Config', 'title, abstract level structure')
     config = Config(title='hello world',
                     abstract='section_test_text',
                     level=0,
                     structure=None)
     section = Section(self._thread_manager, config)
     section.render(ReportManager())
コード例 #2
0
ファイル: test_section.py プロジェクト: mproffitt/pyccata
 def test_render_calls_report_manager_add_methods(self, mock_paragraph):
     Configuration.report_text = 'tests/pyccata.core/data'
     config = DataProviders.get_paragraph_config_for_section()
     section = Section(self._thread_manager, config)
     self.assertEquals(4, len(section._structure))
     for item in section._structure:
         self.assertIsInstance(item, Paragraph)
     section.render(ReportManager())
     calls = [
         call('This is paragraph number 1'),
         call('This is paragraph number 3'),
         call('This is paragraph number 4'),
         call('This is paragraph number 5')
     ]
     mock_paragraph.assert_has_calls(calls)
コード例 #3
0
ファイル: test_section.py プロジェクト: mproffitt/pyccata
    def test_render_returns_if_section_contains_empty_table(
            self, mock_load, mock_jira_client):
        Rows = namedtuple('Row', 'query fields')

        row_config = Rows(query="project=bob and issuetype=Bug",
                          fields=["key", "description", "priority"])
        #rows = Filter(row_config.query, fields=row_config.fields)
        #self._thread_manager.append(rows)
        columns = ['Name', 'Description']

        TableConfig = namedtuple('TableConfig', 'rows columns style')
        table_config = TableConfig(rows=row_config,
                                   columns=columns,
                                   style='Light heading 1')

        StructureConfig = namedtuple('StructureConfig', 'type title content')
        structure_config = StructureConfig(type='table',
                                           title='Hello world',
                                           content=table_config)

        SectionConfig = namedtuple('SectionConfig',
                                   'title abstract level structure')
        section_config = SectionConfig(
            title='Test',
            abstract='This is a test for empty tables',
            level=1,
            structure=[structure_config])

        mock_jira_client.return_value = None
        with patch('pyccata.core.configuration.Configuration.manager',
                   new_callable=PropertyMock) as mock_manager:
            with patch(
                    'pyccata.core.configuration.Configuration._configuration',
                    new_callable=PropertyMock) as mock_config:
                mock_config.return_value = DataProviders._get_config_for_test()
                mock_manager.return_value = 'jira'
                section = Section(self._thread_manager, section_config)
                rows = section._structure[0].rows
                rows._thread_manager = self._thread_manager
                rows._project_manager = ProjectManager()
                rows.projectmanager._client._client = DataProviders._get_client_without_results(
                )

                document = ReportManager()
                self._thread_manager.execute()
                section.render(document)

                self.assertEquals(0, rows.results.total)