def test_build(self):
     """Check report_id with instances created by build method."""
     deployments_report: DeploymentsReport = DeploymentReportFactory.build()
     assert deployments_report.id is None
     assert deployments_report.report_id == deployments_report.id
     # save instance to db. it should have got an id
     deployments_report.save()
     assert deployments_report.id
     # using build method report_id won't match pk
     assert deployments_report.id != deployments_report.report_id
 def test_build_with_defaults(self, patched_randint):
     """Check no fingerprints are created when using build."""
     instance = DeploymentReportFactory.build()
     assert patched_randint.mock_calls == []
     assert instance.id is None
     assert DeploymentsReport.objects.all().count() == 0
     assert SystemFingerprint.objects.all().count() == 0
     # saving deployment won't create fingerprints
     instance.save()
     assert instance.id
     assert SystemFingerprint.objects.all().count() == 0
Beispiel #3
0
def report_entity():
    """Return a report entity with 100 hosts."""
    deployment_report = DeploymentReportFactory.build(id=42)
    fingerprints = SystemFingerprintFactory.build_batch(100)
    return ReportEntity(deployment_report, fingerprints)
 def test_build_setting_number(self):
     """Check for failure when setting number of fingerprints with build method."""
     with pytest.raises(ValueError):
         DeploymentReportFactory.build(number_of_fingerprints=1)