Exemplo n.º 1
0
 def testHangupCause(self):
     obj = HangupCause(code=1, enumeration='UNALLOCATED_NUMBER')
     obj.save()
     self.assertEquals(1, obj.code)
     self.assertNotEquals(obj.id, None)
     obj.delete()
Exemplo n.º 2
0
class CdrModelTestCase(BaseAuthenticatedClient):
    """Test Switch, Alarm, HangupCause models"""

    fixtures = ['auth_user.json', 'hangup_cause.json']

    def setUp(self):
        """Create model object"""
        self.user = User.objects.get(pk=1)

        # Switch model
        self.switch = Switch(name='localhost', ipaddress='127.0.0.1')
        self.switch.save()
        self.assertTrue(self.switch.__unicode__())

        self.hangupcause = HangupCause(code=700,
                                       enumeration='UNALLOCATED_NUMBER')
        self.hangupcause.save()
        self.assertTrue(self.hangupcause.__unicode__())

    def test_functions(self):
        get_switch_list()
        get_hangupcause_name(self.hangupcause.pk)
        get_hangupcause_name(2)

        get_hangupcause_id(self.hangupcause.code)

        # Template tags
        hangupcause_name_with_title(self.hangupcause.pk)
        value = {'_id': {'val': 1}}
        mongo_id(value, 'val')

        get_hc_list()
        get_country_id(['44', '442'])

    def test_cdr_search_form(self):
        data = {
            'switch_id': 1,
            'from_date': datetime.now().strftime("%Y-%m-%d"),
            'to_date': datetime.now().strftime("%Y-%m-%d"),
            'destination': 'abc',
            'destination_type': 1,
            'accountcode': 'abc',
            'caller': 'abc',
            'duration': 'abc',
            'duration_type': '>',
            'direction': 'INBOUND',
            'hangup_cause': 1,
            'result': 1,
            'records_per_page': 10
        }
        form = CdrSearchForm(data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["duration"].errors,
                         ['abc is not a valid duration.'])
        #self.assertEqual(form["accountcode"].errors, ['abc is not a valid accountcode.'])

    def test_email_report_form(self):
        data = {'multiple_email': '[email protected],xyzlocalhost.com'}
        form = EmailReportForm(self.user, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["multiple_email"].errors,
                         ['xyzlocalhost.com is not a valid e-mail address.'])

        data = {'multiple_email': '[email protected],[email protected]'}
        form = EmailReportForm(self.user, data)
        self.assertTrue(form.is_valid())

    def test_model_value(self):
        """Create model object value"""
        self.assertEquals(self.switch.name, 'localhost')
        self.assertEquals(self.hangupcause.enumeration, 'UNALLOCATED_NUMBER')

    def tearDown(self):
        """Delete created object"""
        self.switch.delete()
        self.hangupcause.delete()
Exemplo n.º 3
0
 def testHangupCause(self):
     obj = HangupCause(code=1, enumeration='UNALLOCATED_NUMBER')
     obj.save()
     self.assertEquals(1, obj.code)
     self.assertNotEquals(obj.id, None)
     obj.delete()
Exemplo n.º 4
0
class CdrModelTestCase(BaseAuthenticatedClient):
    """Test Switch, Alarm, HangupCause models"""

    fixtures = ['auth_user.json', 'hangup_cause.json']

    def setUp(self):
        """Create model object"""
        self.user = User.objects.get(pk=1)

        # Switch model
        self.switch = Switch(
            name='localhost',
            ipaddress='127.0.0.1'
        )
        self.switch.save()
        self.assertTrue(self.switch.__unicode__())

        self.hangupcause = HangupCause(
            code=700,
            enumeration='UNALLOCATED_NUMBER'
        )
        self.hangupcause.save()
        self.assertTrue(self.hangupcause.__unicode__())

    def test_functions(self):
        get_switch_list()
        get_hangupcause_name(self.hangupcause.pk)
        get_hangupcause_name(2)

        get_hangupcause_id(self.hangupcause.code)

        # Template tags
        hangupcause_name_with_title(self.hangupcause.pk)
        value = {'_id': {'val': 1}}
        mongo_id(value, 'val')

        get_hc_list()
        get_country_id(['44', '442'])

    def test_cdr_search_form(self):
        data = {'switch_id': 1,
                'from_date': datetime.now().strftime("%Y-%m-%d"),
                'to_date': datetime.now().strftime("%Y-%m-%d"),
                'destination': 'abc',
                'destination_type': 1,
                'accountcode': 'abc',
                'caller': 'abc',
                'duration': 'abc',
                'duration_type': '>',
                'direction': 'INBOUND',
                'hangup_cause': 1,
                'result': 1,
                'records_per_page': 10}
        form = CdrSearchForm(data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["duration"].errors, ['abc is not a valid duration.'])
        #self.assertEqual(form["accountcode"].errors, ['abc is not a valid accountcode.'])

    def test_email_report_form(self):
        data = {'multiple_email': '[email protected],xyzlocalhost.com'}
        form = EmailReportForm(self.user, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["multiple_email"].errors,
            ['xyzlocalhost.com is not a valid e-mail address.'])

        data = {'multiple_email': '[email protected],[email protected]'}
        form = EmailReportForm(self.user, data)
        self.assertTrue(form.is_valid())

    def test_model_value(self):
        """Create model object value"""
        self.assertEquals(self.switch.name, 'localhost')
        self.assertEquals(self.hangupcause.enumeration, 'UNALLOCATED_NUMBER')

    def tearDown(self):
        """Delete created object"""
        self.switch.delete()
        self.hangupcause.delete()