Exemplo n.º 1
0
 def testAlertRemovePrefix(self):
     obj = AlertRemovePrefix(label='test', prefix=32)
     obj.save()
     self.assertEquals('test', obj.label)
     self.assertNotEquals(obj.id, None)
     obj.delete()
Exemplo n.º 2
0
 def testAlertRemovePrefix(self):
     obj = AlertRemovePrefix(label='test', prefix=32)
     obj.save()
     self.assertEquals('test', obj.label)
     self.assertNotEquals(obj.id, None)
     obj.delete()
Exemplo n.º 3
0
    def setUp(self):
        """Create model object"""
        # AlertRemovePrefix model
        self.alert_remove_prefix = AlertRemovePrefix(
            label='test',
            prefix=32
        )
        self.alert_remove_prefix.save()
        self.assertEquals(self.alert_remove_prefix.__unicode__(), 'test')

        # Alarm model
        self.alarm = Alarm(
            name='Alarm name',
            period=1,
            type=1,
            alert_condition=1,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm.save()
        self.assertEquals(self.alarm.__unicode__(), 'Alarm name')

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=2,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=3,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=4,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=5,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=6,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=2,
            type=1,
            alert_condition=3,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=2,
            type=1,
            alert_condition=4,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=3,
            type=1,
            alert_condition=5,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=3,
            type=1,
            alert_condition=6,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        # AlarmReport model
        self.alarm_report = AlarmReport(
            alarm=self.alarm,
            calculatedvalue=10,
            status=1
        )
        self.alarm_report.save()
        self.assertEquals(self.alarm_report.__unicode__(), 'Alarm name')

        self.country = Country.objects.get(pk=198)
        # Blacklist model
        self.blacklist = Blacklist(
            phonenumber_prefix=32,
            country=self.country
        )
        self.blacklist.save()
        self.assertTrue(self.blacklist.__unicode__())

        # Whitelist model
        self.whitelist = Whitelist(
            phonenumber_prefix=32,
            country=self.country
        )
        self.whitelist.save()
        self.assertTrue(self.whitelist.__unicode__())
        chk_destination('9999787424')
Exemplo n.º 4
0
class CdrAlertModelTestCase(TestCase):
    """Test AlertRemovePrefix, Alarm, AlarmReport,
    Blacklist, Whitelist models
    """
    # initial_data.json is taken from country_dialcode
    fixtures = ['auth_user.json', 'country_dialcode.json']

    def setUp(self):
        """Create model object"""
        # AlertRemovePrefix model
        self.alert_remove_prefix = AlertRemovePrefix(
            label='test',
            prefix=32
        )
        self.alert_remove_prefix.save()
        self.assertEquals(self.alert_remove_prefix.__unicode__(), 'test')

        # Alarm model
        self.alarm = Alarm(
            name='Alarm name',
            period=1,
            type=1,
            alert_condition=1,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm.save()
        self.assertEquals(self.alarm.__unicode__(), 'Alarm name')

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=2,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=3,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=4,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=5,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=1,
            type=1,
            alert_condition=6,
            alert_value=10,
            alert_condition_add_on=1,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=2,
            type=1,
            alert_condition=3,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=2,
            type=1,
            alert_condition=4,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=3,
            type=1,
            alert_condition=5,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        self.alarm_new = Alarm(
            name='Alarm name new',
            period=3,
            type=1,
            alert_condition=6,
            alert_value=10,
            alert_condition_add_on=2,
            status=1,
            email_to_send_alarm='*****@*****.**'
        )
        self.alarm_new.save()

        # AlarmReport model
        self.alarm_report = AlarmReport(
            alarm=self.alarm,
            calculatedvalue=10,
            status=1
        )
        self.alarm_report.save()
        self.assertEquals(self.alarm_report.__unicode__(), 'Alarm name')

        self.country = Country.objects.get(pk=198)
        # Blacklist model
        self.blacklist = Blacklist(
            phonenumber_prefix=32,
            country=self.country
        )
        self.blacklist.save()
        self.assertTrue(self.blacklist.__unicode__())

        # Whitelist model
        self.whitelist = Whitelist(
            phonenumber_prefix=32,
            country=self.country
        )
        self.whitelist.save()
        self.assertTrue(self.whitelist.__unicode__())
        chk_destination('9999787424')

    def test_model_value(self):
        """Create model object value"""
        self.assertEquals(self.alert_remove_prefix.label, 'test')
        self.assertNotEquals(self.alert_remove_prefix.id, None)

        self.assertEquals(self.alarm.name, 'Alarm name')
        self.assertEquals(self.alarm_report.alarm, self.alarm)

        self.assertEquals(self.blacklist.country, self.country)
        self.assertEquals(self.blacklist.phonenumber_prefix, 32)

        self.assertEquals(self.whitelist.country, self.country)
        self.assertEquals(self.whitelist.phonenumber_prefix, 32)

    def tearDown(self):
        """Delete created object"""
        self.alert_remove_prefix.delete()
        self.alarm.delete()
        self.alarm_report.delete()
        self.blacklist.delete()
        self.whitelist.delete()

    def test_blacklist_whitelist_notification(self):
        """Test task : blacklist_whitelist_notification"""
        # notice_type = 3 blacklist
        result = blacklist_whitelist_notification.delay(NOTICE_TYPE.blacklist_prefix)
        self.assertEquals(result.get(), True)

        result = blacklist_whitelist_notification.delay(NOTICE_TYPE.whitelist_prefix)
        self.assertEquals(result.get(), True)

    def test_chk_alarm(self):
        """Test task : chk_alarm"""
        result = chk_alarm.delay()
        self.assertEqual(result.get(), True)

    def test_send_cdr_report(self):
        """Test task : send_cdr_report"""
        result = send_cdr_report.delay()
        self.assertEqual(result.get(), True)
Exemplo n.º 5
0
    def setUp(self):
        """Create model object"""
        self.user = User.objects.get(username='******')

        # AlertRemovePrefix model
        self.alert_remove_prefix = AlertRemovePrefix(label='test', prefix=32)
        self.alert_remove_prefix.save()
        self.assertEquals(self.alert_remove_prefix.__unicode__(), 'test')

        # Alarm model
        self.alarm = Alarm(user=self.user,
                           name='Alarm name',
                           period=1,
                           type=1,
                           alert_condition=1,
                           alert_value=10,
                           alert_condition_add_on=1,
                           status=1,
                           email_to_send_alarm='*****@*****.**')
        self.alarm.save()
        self.assertEquals(self.alarm.__unicode__(), 'Alarm name')

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=2,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=3,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=4,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=5,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=6,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=2,
                               type=1,
                               alert_condition=3,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=2,
                               type=1,
                               alert_condition=4,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=3,
                               type=1,
                               alert_condition=5,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=3,
                               type=1,
                               alert_condition=6,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        # AlarmReport model
        self.alarm_report = AlarmReport(alarm=self.alarm,
                                        calculatedvalue=10,
                                        status=1)
        self.alarm_report.save()
        self.assertEquals(self.alarm_report.__unicode__(), 'Alarm name')

        self.country = Country.objects.get(pk=198)
        # Blacklist model
        self.blacklist = Blacklist(user=self.user,
                                   phonenumber_prefix=32,
                                   country=self.country)
        self.blacklist.save()
        self.assertTrue(self.blacklist.__unicode__())

        # Whitelist model
        self.whitelist = Whitelist(user=self.user,
                                   phonenumber_prefix=32,
                                   country=self.country)
        self.whitelist.save()
        self.assertTrue(self.whitelist.__unicode__())
        chk_destination('9999787424')
Exemplo n.º 6
0
class CdrAlertModelTestCase(TestCase):
    """Test AlertRemovePrefix, Alarm, AlarmReport,
    Blacklist, Whitelist models
    """
    # initial_data.json is taken from country_dialcode
    fixtures = [
        'auth_user.json', 'country_dialcode.json', 'notice_type.json',
        'notification.json'
    ]

    def setUp(self):
        """Create model object"""
        self.user = User.objects.get(username='******')

        # AlertRemovePrefix model
        self.alert_remove_prefix = AlertRemovePrefix(label='test', prefix=32)
        self.alert_remove_prefix.save()
        self.assertEquals(self.alert_remove_prefix.__unicode__(), 'test')

        # Alarm model
        self.alarm = Alarm(user=self.user,
                           name='Alarm name',
                           period=1,
                           type=1,
                           alert_condition=1,
                           alert_value=10,
                           alert_condition_add_on=1,
                           status=1,
                           email_to_send_alarm='*****@*****.**')
        self.alarm.save()
        self.assertEquals(self.alarm.__unicode__(), 'Alarm name')

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=2,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=3,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=4,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=5,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=1,
                               type=1,
                               alert_condition=6,
                               alert_value=10,
                               alert_condition_add_on=1,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=2,
                               type=1,
                               alert_condition=3,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=2,
                               type=1,
                               alert_condition=4,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=3,
                               type=1,
                               alert_condition=5,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        self.alarm_new = Alarm(user=self.user,
                               name='Alarm name new',
                               period=3,
                               type=1,
                               alert_condition=6,
                               alert_value=10,
                               alert_condition_add_on=2,
                               status=1,
                               email_to_send_alarm='*****@*****.**')
        self.alarm_new.save()

        # AlarmReport model
        self.alarm_report = AlarmReport(alarm=self.alarm,
                                        calculatedvalue=10,
                                        status=1)
        self.alarm_report.save()
        self.assertEquals(self.alarm_report.__unicode__(), 'Alarm name')

        self.country = Country.objects.get(pk=198)
        # Blacklist model
        self.blacklist = Blacklist(user=self.user,
                                   phonenumber_prefix=32,
                                   country=self.country)
        self.blacklist.save()
        self.assertTrue(self.blacklist.__unicode__())

        # Whitelist model
        self.whitelist = Whitelist(user=self.user,
                                   phonenumber_prefix=32,
                                   country=self.country)
        self.whitelist.save()
        self.assertTrue(self.whitelist.__unicode__())
        chk_destination('9999787424')

    def test_model_value(self):
        """Create model object value"""
        self.assertEquals(self.alert_remove_prefix.label, 'test')
        self.assertNotEquals(self.alert_remove_prefix.id, None)

        self.assertEquals(self.alarm.name, 'Alarm name')
        self.assertEquals(self.alarm_report.alarm, self.alarm)

        self.assertEquals(self.blacklist.country, self.country)
        self.assertEquals(self.blacklist.phonenumber_prefix, 32)

        self.assertEquals(self.whitelist.country, self.country)
        self.assertEquals(self.whitelist.phonenumber_prefix, 32)

    def tearDown(self):
        """Delete created object"""
        self.alert_remove_prefix.delete()
        self.alarm.delete()
        self.alarm_report.delete()
        self.blacklist.delete()
        self.whitelist.delete()

    def test_blacklist_whitelist_notification(self):
        """Test task : blacklist_whitelist_notification"""
        # notice_type = 3 blacklist
        result = blacklist_whitelist_notification.delay(
            NOTICE_TYPE.blacklist_prefix)
        self.assertEquals(result.get(), True)

        result = blacklist_whitelist_notification.delay(
            NOTICE_TYPE.whitelist_prefix)
        self.assertEquals(result.get(), True)

    def test_chk_alarm(self):
        """Test task : chk_alarm"""
        result = chk_alarm.delay()
        self.assertEqual(result.get(), True)

    def test_send_cdr_report(self):
        """Test task : send_cdr_report"""
        result = send_cdr_report.delay()
        self.assertEqual(result.get(), True)