Exemplo n.º 1
0
    def test_to_table_one_per_row_csv(self):

        site = USite.objects.create(name="site")
        unit = utils.create_unit(site=site)
        utc = utils.create_unit_test_collection(unit=unit)
        tli = utils.create_test_list_instance(unit_test_collection=utc)
        ti = utils.create_test_instance(test_list_instance=tli)
        utils.create_test_instance(
            test_list_instance=tli,
            unit_test_info=ti.unit_test_info,
            work_completed=tli.work_completed - timezone.timedelta(days=1),
        )

        rep = qc.TestInstanceDetailsReport(
            report_opts={
                'unit_test_info__test': [ti.unit_test_info.test.pk],
                'organization': 'one_per_row'
            })
        rep.report_format = "csv"
        context = rep.get_context()
        table = rep.to_table(context)
        header_row = table.index([
            _("Work Completed"),
            _("Test"),
            _("Unit"),
            _("Site"),
            _("Value"),
            _("Reference"),
            _("Tolerance"),
            _("Skipped"),
            _("Performed By"),
            _("Comment"),
        ])
        # should be two tis after header
        assert len(table[header_row + 1:]) == 2
Exemplo n.º 2
0
    def test_to_table_group_by_unit_test_date_csv(self):

        site = USite.objects.create(name="site")
        unit = utils.create_unit(site=site)
        utc = utils.create_unit_test_collection(unit=unit)
        tli = utils.create_test_list_instance(unit_test_collection=utc)
        ti = utils.create_test_instance(test_list_instance=tli)
        utils.create_test_instance(
            test_list_instance=tli,
            unit_test_info=ti.unit_test_info,
            work_completed=tli.work_completed - timezone.timedelta(days=1),
        )
        ti3 = utils.create_test_instance(
            test_list_instance=tli,
            work_completed=tli.work_completed - timezone.timedelta(days=1),
        )

        rep = qc.TestInstanceDetailsReport(
            report_opts={
                'unit_test_info__test':
                [ti.unit_test_info.test.pk, ti3.unit_test_info.test.pk],
                'organization':
                'group_by_unit_test_date'
            })
        rep.report_format = "csv"
        context = rep.get_context()
        table = rep.to_table(context)
        org_row = table.index(['Organization:', 'Group by Unit/Test/Date'])

        # should be two rows after blank row
        assert len(table[org_row + 2:]) == 2
        # and 11 columns
        assert len(table[org_row + 3]) == 11
Exemplo n.º 3
0
 def test_filter_form_valid(self):
     """If queryset.count() > MAX_TLIS then filter_form should get an error added"""
     rep = qc.TestInstanceDetailsReport()
     rep.MAX_TIS = -1
     ff = rep.get_filter_form()
     resp = rep.filter_form_valid(ff)
     assert resp is False
     assert '__all__' in ff.errors and "Please reduce" in ff.errors[
         '__all__'][0]
Exemplo n.º 4
0
    def test_generate_html_one_per_row(self):
        site = USite.objects.create(name="site")
        unit = utils.create_unit(site=site)
        utc = utils.create_unit_test_collection(unit=unit)
        tli = utils.create_test_list_instance(unit_test_collection=utc)
        ti = utils.create_test_instance(test_list_instance=tli)

        rep = qc.TestInstanceDetailsReport(
            report_opts={
                'unit_test_info__test': [ti.unit_test_info.test.pk],
                'organization': 'one_per_row'
            })
        rep.report_format = "pdf"
        rep.to_html()
Exemplo n.º 5
0
    def test_generate_html_group_by_unit_test_date(self):
        site = USite.objects.create(name="site")
        unit = utils.create_unit(site=site)
        utc = utils.create_unit_test_collection(unit=unit)
        tli = utils.create_test_list_instance(unit_test_collection=utc)
        ti = utils.create_test_instance(test_list_instance=tli)

        rep = qc.TestInstanceDetailsReport(
            report_opts={
                'unit_test_info__test': [ti.unit_test_info.test.pk],
                'organization': 'group_by_unit_test_date'
            })
        rep.report_format = "pdf"
        assert 'not supported for' in rep.to_html()
Exemplo n.º 6
0
 def test_get_organization_details(self):
     org = qc.TestInstanceDetailsReport().get_organization_details(
         'one_per_row')
     assert org == ('Organization', 'One Test Instance Per Row')
Exemplo n.º 7
0
 def test_get_unit_test_info__test_details(self):
     test = utils.create_test()
     tests = qc.TestInstanceDetailsReport(
     ).get_unit_test_info__test_details([test.pk])
     assert tests == ('Test', test.name)
Exemplo n.º 8
0
 def test_get_filename(self):
     assert qc.TestInstanceDetailsReport().get_filename(
         'pdf') == 'test-instance-details.pdf'
Exemplo n.º 9
0
 def test_get_queryset(self):
     assert qc.TestInstanceDetailsReport().get_queryset(
     ).model._meta.model_name == "testinstance"