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)
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')
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)
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)
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')
def test_minimal_config(self, mock_gf): self.assertTrue(graphite.setup(self.hass, {})) mock_gf.assert_called_once_with(self.hass, 'localhost', 2003, 'ha')