def test_reportmeta_network_list(self): for i in xrange(10): report_meta = ReportMeta(name='report %i' % i, description='description', period=1, object_type=ContentType.objects.get_for_model(Network), object_id=self.network.pk, user=self.user) report_meta.save() response = self.client.get('/report/list/network/') self.assertEqual(response.status_code, 200)
def test_reportmeta_network_list(self): for i in xrange(10): report_meta = ReportMeta( name='report %i' % i, description='description', period=1, object_type=ContentType.objects.get_for_model(Network), object_id=self.network.pk, user=self.user) report_meta.save() response = self.client.get('/report/list/network/') self.assertEqual(response.status_code, 200)
def test_reportmeta_delete(self): ct_host = ContentType.objects.get_for_model(Host) ct_network = ContentType.objects.get_for_model(Network) reportmeta_host = ReportMeta(name='host report', description='description', period=1, object_type=ct_host, object_id=self.host.pk, user=self.user) reportmeta_host.save() reportmeta_host_pk = reportmeta_host.pk reportmeta_net = ReportMeta(name='network report', description='description', period=1, object_type=ct_network, object_id=self.network.pk, user=self.user) reportmeta_net.save() reportmeta_net_pk = reportmeta_net.pk response = self.client.post('/report/delete/%i/' % reportmeta_host.pk) self.assertEqual(response.status_code, 302) self.assertRaises(ReportMeta.DoesNotExist, ReportMeta.objects.get, **{'object_id': reportmeta_host_pk, 'object_type': ct_host}) response = self.client.post('/report/delete/%i/' % reportmeta_net.pk) self.assertEqual(response.status_code, 302) self.assertRaises(ReportMeta.DoesNotExist, ReportMeta.objects.get, **{'object_id': reportmeta_net_pk, 'object_type': ct_network})
def test_reportmeta_update(self): reportmeta_host = ReportMeta(name='host report', description='description', report_period=1, object_type=ContentType.objects.get_for_model(Host), object_id=self.host.pk, user=self.user) reportmeta_host.save() reportmeta_net = ReportMeta(name='network report', description='description', report_period=1, object_type=ContentType.objects.get_for_model(Network), object_id=self.network.pk, user=self.user) reportmeta_net.save() reportmeta_host_data = { 'name': 'Updated host report', 'description': 'Updated host report description', 'report_period': 1, 'object_type': ContentType.objects.get_for_model(Host).pk, 'object_id': self.host.pk, 'user': self.user.pk } reportmeta_network_data = { 'name': 'Updated network report', 'description': 'Updated network report description', 'report_period': 1, 'object_type': ContentType.objects.get_for_model(Network).pk, 'object_id': self.network.pk, 'user': self.user.pk } response = self.client.post('/report/edit/%i/' % reportmeta_host.pk, reportmeta_host_data) self.assertEqual(response.status_code, 302) response = self.client.post('/report/edit/%i/' % reportmeta_net.pk, reportmeta_network_data) self.assertEqual(response.status_code, 302)
def test_reportmeta_update(self): reportmeta_host = ReportMeta( name='host report', description='description', period=1, object_type=ContentType.objects.get_for_model(Host), object_id=self.host.pk, user=self.user) reportmeta_host.save() reportmeta_net = ReportMeta( name='network report', description='description', period=1, object_type=ContentType.objects.get_for_model(Network), object_id=self.network.pk, user=self.user) reportmeta_net.save() reportmeta_host_data = { 'name': 'Updated host report', 'description': 'Updated host report description', 'period': 1, 'send_hour': 12, 'send_day_week': 1, 'send_day_month': 20, 'object_type': ContentType.objects.get_for_model(Host).pk, 'object_id': self.host.pk, 'user': self.user.pk } reportmeta_network_data = { 'name': 'Updated network report', 'description': 'Updated network report description', 'period': 1, 'send_hour': 12, 'send_day_week': 1, 'send_day_month': 20, 'object_type': ContentType.objects.get_for_model(Network).pk, 'object_id': self.network.pk, 'user': self.user.pk } response = self.client.post('/report/edit/%i/' % reportmeta_host.pk, reportmeta_host_data) self.assertEqual(response.status_code, 302) response = self.client.post('/report/edit/%i/' % reportmeta_net.pk, reportmeta_network_data) self.assertEqual(response.status_code, 302)
def test_reportmeta_detail(self): report_meta = ReportMeta( name='host report', description='description', period=1, object_type=ContentType.objects.get_for_model(Host), object_id=self.host.pk, user=self.user) report_meta.save() response = self.client.get('/report/%i/' % report_meta.pk) self.assertEqual(response.status_code, 200) report_meta = ReportMeta( name='network report', description='description', period=1, object_type=ContentType.objects.get_for_model(Network), object_id=self.network.pk, user=self.user) report_meta.save() response = self.client.get('/report/%i/' % report_meta.pk) self.assertEqual(response.status_code, 200)
def test_reportmeta_detail(self): report_meta = ReportMeta(name='host report', description='description', period=1, object_type=ContentType.objects.get_for_model(Host), object_id=self.host.pk, user=self.user) report_meta.save() response = self.client.get('/report/%i/' % report_meta.pk) self.assertEqual(response.status_code, 200) report_meta = ReportMeta(name='network report', description='description', period=1, object_type=ContentType.objects.get_for_model(Network), object_id=self.network.pk, user=self.user) report_meta.save() response = self.client.get('/report/%i/' % report_meta.pk) self.assertEqual(response.status_code, 200)
def test_reportmeta_delete(self): ct_host = ContentType.objects.get_for_model(Host) ct_network = ContentType.objects.get_for_model(Network) reportmeta_host = ReportMeta(name='host report', description='description', period=1, object_type=ct_host, object_id=self.host.pk, user=self.user) reportmeta_host.save() reportmeta_host_pk = reportmeta_host.pk reportmeta_net = ReportMeta(name='network report', description='description', period=1, object_type=ct_network, object_id=self.network.pk, user=self.user) reportmeta_net.save() reportmeta_net_pk = reportmeta_net.pk response = self.client.post('/report/delete/%i/' % reportmeta_host.pk) self.assertEqual(response.status_code, 302) self.assertRaises( ReportMeta.DoesNotExist, ReportMeta.objects.get, **{ 'object_id': reportmeta_host_pk, 'object_type': ct_host }) response = self.client.post('/report/delete/%i/' % reportmeta_net.pk) self.assertEqual(response.status_code, 302) self.assertRaises( ReportMeta.DoesNotExist, ReportMeta.objects.get, **{ 'object_id': reportmeta_net_pk, 'object_type': ct_network })