Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Add a Message Manager for App #1068

Merged
merged 27 commits into from
Feb 10, 2025

Merge branch 'main' into fix/add_message

5b9776e
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

FEAT: Add a Message Manager for App #1068

Merge branch 'main' into fix/add_message
5b9776e
Select commit
Loading
Failed to load commit list.
GitHub Actions / Test Report 3.11 failed Feb 5, 2025 in 0s

39 tests run, 32 passed, 3 skipped, 4 failed.

Annotations

Check failure on line 40 in tests/embedding/test_messages.py

See this annotation in the file changed.

@github-actions github-actions / Test Report 3.11

test_messages.test_message_manager

AttributeError: 'MessageManager' object has no attribute '_message'
Raw output
embedded_app = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

capsys = <_pytest.capture.CaptureFixture object at 0x7f5e59bba750>

    @pytest.mark.embedding
    def test_message_manager(embedded_app, capsys):
        """Test message manager"""
        assert len(embedded_app.messages) == 0
    
        print(embedded_app.messages)
        captured = capsys.readouterr()
        printed_output = captured.out.strip()
        assert "No messages to display." in printed_output
    
>       embedded_app.messages.add("info", "Info message")

tests/embedding/test_messages.py:40: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Pandas is not available. Please pip install pandas to display messages.
severity = 'info', text = 'Info message'

    def add(self, severity: str, text: str):
        """Add a message and update the cache.
    
        Parameters
        ----------
        severity : str
            Severity of the message. Can be "info", "warning", or "error".
        text : str
            Message text.
    
        Examples
        --------
        >>> app.messages.add("info", "User clicked the start button.")
        """
        severity_map = {
            "info": self._message_severity.Info,
            "warning": self._message_severity.Warning,
            "error": self._message_severity.Error,
        }
    
        if severity.lower() not in severity_map:
            raise ValueError(f"Invalid severity: {severity}")
    
>       _msg = self._message(text, severity_map[severity.lower()])
E       AttributeError: 'MessageManager' object has no attribute '_message'

src/ansys/mechanical/core/embedding/messages.py:123: AttributeError

Check failure on line 51 in tests/embedding/test_messages.py

See this annotation in the file changed.

@github-actions github-actions / Test Report 3.11

test_messages.test_message_add_and_clear

AttributeError: 'MessageManager' object has no attribute '_message'
Raw output
embedded_app = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44


    @pytest.mark.embedding
    def test_message_add_and_clear(embedded_app):
        """Test adding and clearing messages"""
>       embedded_app.messages.add("info", "Info message")

tests/embedding/test_messages.py:51: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Pandas is not available. Please pip install pandas to display messages.
severity = 'info', text = 'Info message'

    def add(self, severity: str, text: str):
        """Add a message and update the cache.
    
        Parameters
        ----------
        severity : str
            Severity of the message. Can be "info", "warning", or "error".
        text : str
            Message text.
    
        Examples
        --------
        >>> app.messages.add("info", "User clicked the start button.")
        """
        severity_map = {
            "info": self._message_severity.Info,
            "warning": self._message_severity.Warning,
            "error": self._message_severity.Error,
        }
    
        if severity.lower() not in severity_map:
            raise ValueError(f"Invalid severity: {severity}")
    
>       _msg = self._message(text, severity_map[severity.lower()])
E       AttributeError: 'MessageManager' object has no attribute '_message'

src/ansys/mechanical/core/embedding/messages.py:123: AttributeError

Check failure on line 79 in tests/embedding/test_messages.py

See this annotation in the file changed.

@github-actions github-actions / Test Report 3.11

test_messages.test_message_show

AttributeError: 'MessageManager' object has no attribute '_message'
Raw output
embedded_app = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

capsys = <_pytest.capture.CaptureFixture object at 0x7f5e59bd5610>

    @pytest.mark.embedding
    def test_message_show(embedded_app, capsys):
        """Test showing messages"""
        print(embedded_app.messages.show())
        captured = capsys.readouterr()
        printed_output = captured.out.strip()
        assert "No messages to display." in printed_output
    
>       embedded_app.messages.add("info", "Info message")

tests/embedding/test_messages.py:79: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Pandas is not available. Please pip install pandas to display messages.
severity = 'info', text = 'Info message'

    def add(self, severity: str, text: str):
        """Add a message and update the cache.
    
        Parameters
        ----------
        severity : str
            Severity of the message. Can be "info", "warning", or "error".
        text : str
            Message text.
    
        Examples
        --------
        >>> app.messages.add("info", "User clicked the start button.")
        """
        severity_map = {
            "info": self._message_severity.Info,
            "warning": self._message_severity.Warning,
            "error": self._message_severity.Error,
        }
    
        if severity.lower() not in severity_map:
            raise ValueError(f"Invalid severity: {severity}")
    
>       _msg = self._message(text, severity_map[severity.lower()])
E       AttributeError: 'MessageManager' object has no attribute '_message'

src/ansys/mechanical/core/embedding/messages.py:123: AttributeError

Check failure on line 113 in tests/embedding/test_messages.py

See this annotation in the file changed.

@github-actions github-actions / Test Report 3.11

test_messages.test_message_get

AssertionError: assert ('AM' in '02/05/2025 17:40:31' or 'PM' in '02/05/2025 17:40:31')
 +  where '02/05/2025 17:40:31' = str(<System.DateTime object at 0x7f5ea50da100>)
 +    where <System.DateTime object at 0x7f5ea50da100> = <Ansys.Mechanical.Application.Message object at 0x7f5ea50c5b40>.TimeStamp
 +  and   '02/05/2025 17:40:31' = str(<System.DateTime object at 0x7f5ea50d8ec0>)
 +    where <System.DateTime object at 0x7f5ea50d8ec0> = <Ansys.Mechanical.Application.Message object at 0x7f5ea50c5b40>.TimeStamp
Raw output
embedded_app = Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

assets = PosixPath('/__w/pymechanical/pymechanical/tests/assets')
capsys = <_pytest.capture.CaptureFixture object at 0x7f5ea50c7d10>

    @pytest.mark.embedding
    def test_message_get(embedded_app, assets, capsys):
        """Test getting a message"""
        with pytest.raises(IndexError):
            embedded_app.messages[0]
    
        embedded_app.open(os.path.join(assets, "cube-hole.mechdb"))
        _msg1 = embedded_app.messages[0]
    
        print(embedded_app.messages[0])
        captured = capsys.readouterr()
        printed_output = captured.out.strip()
        assert "Ansys.Mechanical.Application.Message" in printed_output
    
        assert str(_msg1.Severity) == "Warning"
        assert "Image file not found" in _msg1.DisplayString
>       assert "AM" in str(_msg1.TimeStamp) or "PM" in str(_msg1.TimeStamp)
E       AssertionError: assert ('AM' in '02/05/2025 17:40:31' or 'PM' in '02/05/2025 17:40:31')
E        +  where '02/05/2025 17:40:31' = str(<System.DateTime object at 0x7f5ea50da100>)
E        +    where <System.DateTime object at 0x7f5ea50da100> = <Ansys.Mechanical.Application.Message object at 0x7f5ea50c5b40>.TimeStamp
E        +  and   '02/05/2025 17:40:31' = str(<System.DateTime object at 0x7f5ea50d8ec0>)
E        +    where <System.DateTime object at 0x7f5ea50d8ec0> = <Ansys.Mechanical.Application.Message object at 0x7f5ea50c5b40>.TimeStamp

tests/embedding/test_messages.py:113: AssertionError