Exemplo n.º 1
0
    def test_file_path(self):
        "Test the 'file_path' property."
        value = MagicMock(spec=str)
        rule = styles.ConstantRule(None, None)
        rule._file_path = value

        self.assertEqual(rule.file_path, value)
Exemplo n.º 2
0
    def test_name(self):
        """Test the 'name' property."""
        value = MagicMock(spec=str)
        rule = styles.ConstantRule(None, None)
        rule._name = value

        self.assertEqual(rule.name, value)
Exemplo n.º 3
0
    def test___ne___different_type(self, mock_eq):
        """Test the ne operator when the other item isn't a StyleConstant."""
        constant = styles.ConstantRule(None, None)

        result = constant.__ne__(MagicMock())

        self.assertEqual(result, NotImplemented)
Exemplo n.º 4
0
    def test___ne__(self, mock_eq):
        """Test the ne operator."""
        constant = styles.ConstantRule(None, None)
        mock_constant = MagicMock(spec=styles.ConstantRule)

        result = constant.__ne__(mock_constant)

        self.assertEqual(result, not mock_eq.return_value)
Exemplo n.º 5
0
    def test___hash__(self, mock_name_prop, mock_constant_prop):
        """Test the hash operator."""
        constant = styles.ConstantRule(None, None)

        result = constant.__hash__()

        self.assertEqual(result, hash((constant.constant_name, constant.name)))

        self.assertEqual(hash(constant),
                         hash((constant.constant_name, constant.name)))
Exemplo n.º 6
0
    def test___init__(self, mocker):
        """Test the constructor."""
        mock_name = mocker.MagicMock(spec=str)
        mock_constant_name = mocker.MagicMock(spec=str)
        mock_file_path = mocker.MagicMock(spec=str)

        rule = styles.ConstantRule(mock_name, mock_constant_name, mock_file_path)

        assert rule._name == mock_name
        assert rule._constant_name == mock_constant_name
        assert rule._file_path == mock_file_path
Exemplo n.º 7
0
    def test___init__(self):
        """Test the constructor."""
        mock_name = MagicMock(spec=str)
        mock_constant_name = MagicMock(spec=str)
        mock_file_path = MagicMock(spec=str)

        rule = styles.ConstantRule(mock_name, mock_constant_name,
                                   mock_file_path)

        self.assertEqual(rule._name, mock_name)
        self.assertEqual(rule._constant_name, mock_constant_name)
        self.assertEqual(rule._file_path, mock_file_path)
Exemplo n.º 8
0
    def test___eq__(self, mock_name_prop):
        """Test the equality operator."""
        constant = styles.ConstantRule(None, None)

        mock_name_prop.return_value = "name1"

        mock_constant = MagicMock(spec=styles.ConstantRule)
        mock_constant.name = "name2"

        self.assertNotEqual(constant, mock_constant)

        mock_name_prop.return_value = "name"
        mock_constant.name = "name"

        self.assertEqual(constant, mock_constant)
Exemplo n.º 9
0
 def _create():
     return styles.ConstantRule(None, None)