示例#1
0
 def test_config_bad_port(self, mock_gf):
     config = {
         'graphite': {
             'host': 'foo',
             'port': 'wrong',
         }
     }
     self.assertFalse(graphite.setup(self.hass, config))
     self.assertFalse(mock_gf.called)
示例#2
0
 def test_config_bad_port(self, mock_gf):
     config = {
         'graphite': {
             'host': 'foo',
             'port': 'wrong',
         }
     }
     self.assertFalse(graphite.setup(self.hass, config))
     self.assertFalse(mock_gf.called)
示例#3
0
 def test_full_config(self, mock_gf):
     config = {
         'graphite': {
             'host': 'foo',
             'port': 123,
             'prefix': 'me',
         }
     }
     self.assertTrue(graphite.setup(self.hass, config))
     mock_gf.assert_called_once_with(self.hass, 'foo', 123, 'me')
示例#4
0
 def test_full_config(self, mock_gf):
     config = {
         'graphite': {
             'host': 'foo',
             'port': 123,
             'prefix': 'me',
         }
     }
     self.assertTrue(graphite.setup(self.hass, config))
     mock_gf.assert_called_once_with(self.hass, 'foo', 123, 'me')
示例#5
0
    def test_config_port(self, mock_gf, mock_socket):
        """Test setup with invalid port."""
        config = {
            'graphite': {
                'host': 'foo',
                'port': 2003,
            }
        }

        self.assertTrue(graphite.setup(self.hass, config))
        self.assertTrue(mock_gf.called)
        mock_socket.assert_called_once_with(socket.AF_INET, socket.SOCK_STREAM)
示例#6
0
    def test_config_port(self, mock_gf, mock_socket):
        """Test setup with invalid port."""
        config = {
            'graphite': {
                'host': 'foo',
                'port': 2003,
            }
        }

        self.assertTrue(graphite.setup(self.hass, config))
        self.assertTrue(mock_gf.called)
        mock_socket.assert_called_once_with(socket.AF_INET, socket.SOCK_STREAM)
示例#7
0
    def test_full_config(self, mock_gf, mock_socket):
        """Test setup with full configuration."""
        config = {
            'graphite': {
                'host': 'foo',
                'port': 123,
                'prefix': 'me',
            }
        }

        self.assertTrue(graphite.setup(self.hass, config))
        mock_gf.assert_called_once_with(self.hass, 'foo', 123, 'me')
        mock_socket.assert_called_once_with(socket.AF_INET, socket.SOCK_STREAM)
示例#8
0
    def test_full_config(self, mock_gf, mock_socket):
        """Test setup with full configuration."""
        config = {
            'graphite': {
                'host': 'foo',
                'port': 123,
                'prefix': 'me',
            }
        }

        self.assertTrue(graphite.setup(self.hass, config))
        mock_gf.assert_called_once_with(self.hass, 'foo', 123, 'me')
        mock_socket.assert_called_once_with(socket.AF_INET, socket.SOCK_STREAM)
示例#9
0
 def test_minimal_config(self, mock_gf):
     """Test setup with minimal configuration."""
     self.assertTrue(graphite.setup(self.hass, {}))
     mock_gf.assert_called_once_with(self.hass, 'localhost', 2003, 'ha')
示例#10
0
 def test_minimal_config(self, mock_gf):
     self.assertTrue(graphite.setup(self.hass, {}))
     mock_gf.assert_called_once_with(self.hass, 'localhost', 2003, 'ha')