def chk_prefix_in_blacklist(prefix_list):
    """Check destination no with ban prefix

    >>> chk_prefix_in_blacklist([34, 345, 3456])
    True

    >>> chk_prefix_in_blacklist([])
    True
    """
    if not prefix_list:
        return True
    banned_prefix_list = Blacklist.objects.all()
    flag = False
    if banned_prefix_list:
        for j in eval(prefix_list):
            for i in banned_prefix_list:
                # Banned Prefix
                if i.phonenumber_prefix == j:
                    flag = True
                    break

            # if flag is true - not allowed
            if flag:
                # notice_type = 3 blacklist
                blacklist_whitelist_notification.delay(3)
                return False

    # no blacklist is defined
    return True
def chk_prefix_in_whitelist(prefix_list):
    """Check destination no with allowed prefix

    >>> chk_prefix_in_whitelist([34, 345, 3456])
    False

    >>> chk_prefix_in_whitelist('')
    False
    """
    if not prefix_list:
        return False
    white_prefix_list = Whitelist.objects.all()
    flag = False
    if white_prefix_list:
        for j in eval(prefix_list):
            for i in white_prefix_list:
                # Allowed Prefix
                if i.phonenumber_prefix == j:
                    flag = True
                    break

            # if flag is true - allowed
            if flag:
                # notice_type = 4 whitelist
                blacklist_whitelist_notification.delay(4)
                return True

    # no whitelist define
    return False
def chk_prefix_in_blacklist(prefix_list):
    """Check destination no with ban prefix

    >>> chk_prefix_in_blacklist([34, 345, 3456])
    True

    >>> chk_prefix_in_blacklist([])
    True
    """
    if not prefix_list:
        return True
    banned_prefix_list = Blacklist.objects.all()
    flag = False
    if banned_prefix_list:
        for j in eval(prefix_list):
            for i in banned_prefix_list:
                # Banned Prefix
                if i.phonenumber_prefix == j:
                    flag = True
                    break

            # if flag is true - not allowed
            if flag:
                # notice_type = 3 blacklist
                blacklist_whitelist_notification.delay(3)
                return False

    # no blacklist is defined
    return True
def chk_prefix_in_whitelist(prefix_list):
    """Check destination no with allowed prefix

    >>> chk_prefix_in_whitelist([34, 345, 3456])
    False

    >>> chk_prefix_in_whitelist('')
    False
    """
    if not prefix_list:
        return False
    white_prefix_list = Whitelist.objects.all()
    flag = False
    if white_prefix_list:
        for j in eval(prefix_list):
            for i in white_prefix_list:
                # Allowed Prefix
                if i.phonenumber_prefix == j:
                    flag = True
                    break

            # if flag is true - allowed
            if flag:
                # notice_type = 4 whitelist
                blacklist_whitelist_notification.delay(4)
                return True

    # no whitelist define
    return False
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #7
0
    def testTask(self):
        # notice_type = 3 blacklist
        result = blacklist_whitelist_notification.delay(3)
        self.assertEquals(result.get(), True)
        # notice_type = 4 whitelist
        result = blacklist_whitelist_notification.delay(4)
        self.assertEquals(result.get(), True)

        # PeriodicTask
        result = chk_alarm().run()
        self.assertEquals(result, True)

        delta = timedelta(seconds=1)
        self.assertEqual(get_channels_info().timedelta_seconds(delta), 1)

        delta = timedelta(seconds=1)
        self.assertEqual(sync_cdr_pending().timedelta_seconds(delta), 1)

        delta = timedelta(seconds=1)
        self.assertEqual(send_cdr_report().timedelta_seconds(delta), 1)
Exemple #8
0
    def testTask(self):
        # notice_type = 3 blacklist
        result = blacklist_whitelist_notification.delay(3)
        self.assertEquals(result.get(), True)
        # notice_type = 4 whitelist
        result = blacklist_whitelist_notification.delay(4)
        self.assertEquals(result.get(), True)

        # PeriodicTask
        result = chk_alarm().run()
        self.assertEquals(result, True)

        delta = timedelta(seconds=1)
        self.assertEqual(get_channels_info().timedelta_seconds(delta), 1)

        delta = timedelta(seconds=1)
        self.assertEqual(sync_cdr_pending().timedelta_seconds(delta), 1)

        delta = timedelta(seconds=1)
        self.assertEqual(send_cdr_report().timedelta_seconds(delta), 1)