from django.test import TestCase

from graphite import util
from graphite.wsgi import application  # NOQA makes sure we have a working WSGI app


class UtilTest(TestCase):
    def test_is_local_interface(self):
        addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8']
        results = [ util.is_local_interface(a) for a in addresses ]
        self.assertEqual( results, [True, True, False] )

from django.test import TestCase

from graphite import util
from graphite.wsgi import application  # NOQA makes sure we have a working WSGI app


class UtilTest(TestCase):
    def test_is_local_interface(self):
        addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8']
        results = [ util.is_local_interface(a) for a in addresses ]
        self.assertEqual( results, [True, True, False] )

        addresses = ['::1', '[::1]:8080' ]
        results = [ util.is_local_interface(a) for a in addresses ]
        self.assertEqual( results, [True, True] )

        with self.assertRaises(Exception):
            addresses = ['::1:8080']
            results = [ util.is_local_interface(a) for a in addresses ]

    def test_write_index(self):
        self.assertEqual(None, util.write_index() )

Add coverage to util.py for IPv6 and make_index
Add coverage to util.py for IPv6 and make_index

  from django.test import TestCase
  
  from graphite import util
  from graphite.wsgi import application  # NOQA makes sure we have a working WSGI app
  
  
  class UtilTest(TestCase):
      def test_is_local_interface(self):
          addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8']
          results = [ util.is_local_interface(a) for a in addresses ]
          self.assertEqual( results, [True, True, False] )
  
+         addresses = ['::1', '[::1]:8080' ]
+         results = [ util.is_local_interface(a) for a in addresses ]
+         self.assertEqual( results, [True, True] )
+ 
+         with self.assertRaises(Exception):
+             addresses = ['::1:8080']
+             results = [ util.is_local_interface(a) for a in addresses ]
+ 
+     def test_write_index(self):
+         self.assertEqual(None, util.write_index() )
+ 
Add coverage to util.py for IPv6 and make_index
## Code Before:
from django.test import TestCase

from graphite import util
from graphite.wsgi import application  # NOQA makes sure we have a working WSGI app


class UtilTest(TestCase):
    def test_is_local_interface(self):
        addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8']
        results = [ util.is_local_interface(a) for a in addresses ]
        self.assertEqual( results, [True, True, False] )

## Instruction:
Add coverage to util.py for IPv6 and make_index
## Code After:
from django.test import TestCase

from graphite import util
from graphite.wsgi import application  # NOQA makes sure we have a working WSGI app


class UtilTest(TestCase):
    def test_is_local_interface(self):
        addresses = ['127.0.0.1', '127.0.0.1:8080', '8.8.8.8']
        results = [ util.is_local_interface(a) for a in addresses ]
        self.assertEqual( results, [True, True, False] )

        addresses = ['::1', '[::1]:8080' ]
        results = [ util.is_local_interface(a) for a in addresses ]
        self.assertEqual( results, [True, True] )

        with self.assertRaises(Exception):
            addresses = ['::1:8080']
            results = [ util.is_local_interface(a) for a in addresses ]

    def test_write_index(self):
        self.assertEqual(None, util.write_index() )
