def test_name(self): """Test the 'name' property.""" value = MagicMock(spec=str) constant = styles.StyleConstant(None, None, None, None) constant._name = value self.assertEqual(constant.name, value)
def test___ne___different_type(self, mock_eq): """Test the ne operator when the other item isn't a StyleConstant.""" constant = styles.StyleConstant(None, None, None, None) result = constant.__ne__(MagicMock()) self.assertEqual(result, NotImplemented)
def test_file_path(self): """Test the 'file_path' property.""" value = MagicMock(spec=str) constant = styles.StyleConstant(None, None, None, None) constant._file_path = value self.assertEqual(constant.file_path, value)
def test_shape(self): """Test the 'shape' property.""" value1 = MagicMock(spec=str) constant = styles.StyleConstant(None, None, None, None) constant._shape = value1 self.assertEqual(constant.shape, value1)
def test_color(self): """Test the 'color' property.""" mock_color1 = MagicMock(spec=hou.Color) constant = styles.StyleConstant(None, None, None, None) constant._color = mock_color1 self.assertEqual(constant.color, mock_color1)
def test___ne__(self, mock_eq): """Test the ne operator.""" constant = styles.StyleConstant(None, None, None, None) mock_constant = MagicMock(spec=styles.StyleConstant) result = constant.__ne__(mock_constant) self.assertEqual(result, not mock_eq.return_value)
def test___hash__(self, mock_name_prop): """Test the hash operator.""" constant = styles.StyleConstant(None, None, None, None) result = constant.__hash__() self.assertEqual(result, hash(constant.name)) self.assertEqual(hash(constant), hash(constant.name))
def test_apply_to_node__none(self, mock_color, mock_shape): """Test applying to a node when no values will be set.""" mock_node = MagicMock(spec=hou.Node) constant = styles.StyleConstant(None, None, None, None) constant.apply_to_node(mock_node) mock_node.setColor.assert_not_called() mock_node.setUserData.assert_not_called()
def test_color_type(self): """Test the 'color_type' property.""" value1 = MagicMock(spec=str) constant = styles.StyleConstant(None, None, None, None) constant._color_type = value1 self.assertEqual(constant.color_type, value1) value2 = MagicMock(spec=str) constant.color_type = value2 self.assertEqual(constant._color_type, value2)
def test_apply_to_node__both(self, mock_color_prop, mock_shape_prop): """Test applying everything to a node.""" mock_node = MagicMock(spec=hou.Node) constant = styles.StyleConstant(None, None, None, None) constant.apply_to_node(mock_node) mock_node.setColor.assert_called_with(mock_color_prop.return_value) mock_node.setUserData.assert_called_with("nodeshape", mock_shape_prop.return_value)
def test___eq__(self, mock_name_prop): """Test the equality operator.""" mock_name_prop.return_value = "name1" constant = styles.StyleConstant(None, None, None, None) mock_constant = MagicMock(spec=styles.StyleConstant) mock_constant.name = "name2" self.assertNotEqual(constant, mock_constant) mock_name_prop.return_value = "name" mock_constant.name = "name" self.assertEqual(constant, mock_constant)
def test___init__(self, mocker): """Test object initialization.""" mock_name = mocker.MagicMock(spec=str) mock_color = mocker.MagicMock(spec=hou.Color) mock_color_type = mocker.MagicMock(spec=str) mock_shape = mocker.MagicMock(spec=str) mock_file_path = mocker.MagicMock(spec=str) constant = styles.StyleConstant(mock_name, mock_color, mock_color_type, mock_shape, mock_file_path) assert constant._name == mock_name assert constant._color == mock_color assert constant._color_type == mock_color_type assert constant._shape == mock_shape assert constant._file_path == mock_file_path
def test___init__(self): """Test the constructor""" mock_name = MagicMock(spec=str) mock_color = MagicMock(spec=hou.Color) mock_color_type = MagicMock(spec=str) mock_shape = MagicMock(spec=str) mock_file_path = MagicMock(spec=str) constant = styles.StyleConstant(mock_name, mock_color, mock_color_type, mock_shape, mock_file_path) self.assertEqual(constant._name, mock_name) self.assertEqual(constant._color, mock_color) self.assertEqual(constant._color_type, mock_color_type) self.assertEqual(constant._shape, mock_shape) self.assertEqual(constant._file_path, mock_file_path)
def _create(): return styles.StyleConstant(None, None, None, None)