Beispiel #1
0
    def test_get_user_agent_default(self):
        """
        Test that getting a user agent on a non-Linux/Windows/OS X platform returns the default user agent
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is something else
            mocked_sys.platform = 'freebsd'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            assert 'NetBSD'in user_agent, 'The user agent should be the default user agent'
Beispiel #2
0
    def test_get_user_agent_windows(self):
        """
        Test that getting a user agent on Windows returns a user agent suitable for Windows
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is Windows
            mocked_sys.platform = 'win32'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            assert 'Windows' in user_agent, 'The user agent should be a valid Windows user agent'
Beispiel #3
0
    def test_get_user_agent_macos(self):
        """
        Test that getting a user agent on OS X returns a user agent suitable for OS X
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is macOS
            mocked_sys.platform = 'darwin'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            assert 'Mac OS X' in user_agent, 'The user agent should be a valid OS X user agent'
Beispiel #4
0
    def test_get_user_agent_default(self):
        """
        Test that getting a user agent on a non-Linux/Windows/OS X platform returns the default user agent
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is Linux
            mocked_sys.platform = 'freebsd'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            self.assertIn('NetBSD', user_agent, 'The user agent should be the default user agent')
Beispiel #5
0
    def test_get_user_agent_macos(self):
        """
        Test that getting a user agent on OS X returns a user agent suitable for OS X
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is Linux
            mocked_sys.platform = 'darwin'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            self.assertIn('Mac OS X', user_agent, 'The user agent should be a valid OS X user agent')
Beispiel #6
0
    def test_get_user_agent_windows(self):
        """
        Test that getting a user agent on Windows returns a user agent suitable for Windows
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is Linux
            mocked_sys.platform = 'win32'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            self.assertIn('Windows', user_agent, 'The user agent should be a valid Windows user agent')
Beispiel #7
0
    def test_get_user_agent_linux(self):
        """
        Test that getting a user agent on Linux returns a user agent suitable for Linux
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is Linux
            mocked_sys.platform = 'linux2'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            result = 'Linux' in user_agent or 'CrOS' in user_agent
            assert result is True, 'The user agent should be a valid Linux user agent'
Beispiel #8
0
    def test_get_user_agent_linux(self):
        """
        Test that getting a user agent on Linux returns a user agent suitable for Linux
        """
        with patch('openlp.core.common.httputils.sys') as mocked_sys:

            # GIVEN: The system is Linux
            mocked_sys.platform = 'linux2'

            # WHEN: We call get_user_agent()
            user_agent = get_user_agent()

            # THEN: The user agent is a Linux (or ChromeOS) user agent
            result = 'Linux' in user_agent or 'CrOS' in user_agent
            self.assertTrue(result, 'The user agent should be a valid Linux user agent')