Repository: iossifovlab/gpf

Issue:
[BUG] Denovo report missing in representation when empty
**What happened**:
Generating a common report on a study without denovo variants results in a missing denovo report in the final output.

**What you expected to happen**:
The frontend expects the denovo report to be an empty list of tables instead of missing.

Discussion:

Patch:
diff --git a/dae/dae/common_reports/common_report.py b/dae/dae/common_reports/common_report.py
index 49cc4d0eb..114c100fb 100644
--- a/dae/dae/common_reports/common_report.py
+++ b/dae/dae/common_reports/common_report.py
@@ -125,8 +125,6 @@ class CommonReport:
             "families_report": families_report.to_dict(full=True),
             "denovo_report": (
                 denovo_report.to_dict()
-                if not denovo_report.is_empty()
-                else None
             ),
             "study_name": genotype_data_study.name,
             "phenotype": phenotype,
@@ -148,8 +146,6 @@ class CommonReport:
             "families_report": self.families_report.to_dict(full=full),
             "denovo_report": (
                 self.denovo_report.to_dict()
-                if not self.denovo_report.is_empty()
-                else None
             ),
             "study_name": self.study_name,
             "phenotype": self.phenotype,


Test patch:
diff --git a/dae/dae/common_reports/tests/test_common_report.py b/dae/dae/common_reports/tests/test_common_report.py
index 3dda55a09..de168fc94 100644
--- a/dae/dae/common_reports/tests/test_common_report.py
+++ b/dae/dae/common_reports/tests/test_common_report.py
@@ -1,5 +1,6 @@
 # pylint: disable=W0621,C0114,C0116,W0212,W0613
 from dae.common_reports.common_report import CommonReport
+from dae.common_reports.denovo_report import DenovoReport
 
 
 def test_common_report(study4):
@@ -22,3 +23,33 @@ def test_common_report(study4):
 
     assert len(common_report.to_dict()) == 15
     print(common_report.to_dict())
+
+
+def test_common_report_empty_denovo(study4, mocker):
+    denovo_report_mock = mocker.Mock(return_value=DenovoReport({"tables": []}))
+    mocker.patch(
+        "dae.common_reports.common_report."
+        "DenovoReport.from_genotype_study",
+        new=denovo_report_mock
+    )
+
+    common_report = CommonReport.build_report(study4)
+
+    assert common_report.study_id == "Study4"
+    assert common_report.families_report
+    assert common_report.denovo_report is not None
+    assert common_report.study_name == "Study4"
+    assert common_report.phenotype == ["phenotype1", "unaffected"]
+    assert common_report.study_type == "WE"
+    assert not common_report.study_year
+    assert not common_report.pub_med
+    assert common_report.families == 3
+    assert common_report.number_of_probands == 3
+    assert common_report.number_of_siblings == 9
+    assert common_report.denovo is True
+    assert common_report.transmitted is False
+    assert common_report.study_description is None
+
+    assert len(common_report.to_dict()) == 15
+    assert common_report.to_dict()["denovo_report"] is not None
+    print(common_report.to_dict())