示例#1
0
    def test_file_path(self):
        """Test the 'file_path' property."""
        value = MagicMock(spec=str)
        rule = styles.StyleRule(None, None, None, None)
        rule._file_path = value

        self.assertEqual(rule.file_path, value)
示例#2
0
    def test_shape(self):
        """Test the 'shape' property."""
        value = MagicMock(spec=str)
        rule = styles.StyleRule(None, None, None, None)
        rule._shape = value

        self.assertEqual(rule.shape, value)
示例#3
0
    def test___str__(self, mock_typed):
        """Test converting the object to a string."""
        mock_typed.return_value = (0.46700000762939453, 1.0, 0.5)

        rule = styles.StyleRule(None, None, None, None)

        self.assertEqual(str(rule), "(0.467, 1, 0.5)")
示例#4
0
    def test___ne___different_type(self, mock_eq):
        """Test the ne operator when the other item isn't a StyleConstant."""
        rule = styles.StyleRule(None, None, None, None)

        result = rule.__ne__(MagicMock())

        self.assertEqual(result, NotImplemented)
示例#5
0
    def test_color(self):
        """Test the 'color' property."""
        mock_color = MagicMock(spec=hou.Color)

        rule = styles.StyleRule(None, None, None, None)
        rule._color = mock_color

        self.assertEqual(rule.color, mock_color)
示例#6
0
    def test___ne__(self, mock_eq):
        """Test the ne operator."""
        rule = styles.StyleRule(None, None, None, None)

        mock_rule = MagicMock(spec=styles.StyleRule)

        result = rule.__ne__(mock_rule)

        self.assertEqual(result, not mock_eq.return_value)
示例#7
0
    def test___hash__(self, mock_name_prop):
        """Test the hash operator."""
        rule = styles.StyleRule(None, None, None, None)

        result = rule.__hash__()

        self.assertEqual(result, hash(rule.name))

        self.assertEqual(hash(rule), hash(rule.name))
示例#8
0
    def test_apply_to_node__none(self, mock_color_prop, mock_shape_prop):
        """Test applying to a node when no values will be set."""
        mock_node = MagicMock(spec=hou.Node)

        rule = styles.StyleRule(None, None, None, None)

        rule.apply_to_node(mock_node)

        mock_node.setColor.assert_not_called()
        mock_node.setUserData.assert_not_called()
示例#9
0
    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)

        rule = styles.StyleRule(None, None, None, None)

        rule.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)
示例#10
0
    def test___eq__(self, mock_name_prop):
        """Test the equality operator."""
        rule = styles.StyleRule(None, None, None, None)

        mock_rule = MagicMock(spec=styles.StyleRule)
        mock_rule.name = "different_name"

        self.assertNotEqual(rule, mock_rule)

        mock_rule.name = "name"
        self.assertEqual(rule, mock_rule)
示例#11
0
    def test__get_typed_color_value(self, mock_color_prop,
                                    mock_color_type_prop):
        """Test getting a typed color value."""
        value = (1, 2, 3)

        mock_color = MagicMock(spec=hou.Color)
        mock_color.hsv.return_value = value

        mock_color_prop.return_value = mock_color

        rule = styles.StyleRule(None, None, None, None)

        result = rule._get_typed_color_value()
        self.assertEqual(result, value)
示例#12
0
    def test___init__(self, mocker):
        """Test the constructor."""
        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)

        rule = styles.StyleRule(mock_name, mock_color, mock_color_type,
                                mock_shape, mock_file_path)

        assert rule._name == mock_name
        assert rule._color == mock_color
        assert rule._color_type == mock_color_type
        assert rule._shape == mock_shape
        assert rule._file_path == mock_file_path
示例#13
0
    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)

        rule = styles.StyleRule(mock_name, mock_color, mock_color_type,
                                mock_shape, mock_file_path)

        self.assertEqual(rule._name, mock_name)
        self.assertEqual(rule._color, mock_color)
        self.assertEqual(rule._color_type, mock_color_type)
        self.assertEqual(rule._shape, mock_shape)
        self.assertEqual(rule._file_path, mock_file_path)
示例#14
0
 def _create():
     return styles.StyleRule(None, None, None, None)