def test_recent_users(self):
        """
        Makes sure the recent hosts list is keep up to date.
        """
        HOST = "https://host.shotgunstudio.com"
        LOGIN_A = "login_a"
        LOGIN_B = "login_b"

        self._clear_site_yml(HOST)

        # Make sure the recent hosts is initially empty.
        self.assertEqual(session_cache.get_recent_users(HOST), [])

        # Set HOST_A as the current host.
        session_cache.set_current_user(HOST, LOGIN_A)
        self.assertEqual(session_cache.get_recent_users(HOST), [LOGIN_A])
        self.assertEqual(session_cache.get_current_user(HOST), LOGIN_A)

        # Then set HOST_B as the new current host.
        session_cache.set_current_user(HOST, LOGIN_B)
        self.assertEqual(session_cache.get_recent_users(HOST),
                         [LOGIN_B, LOGIN_A])
        self.assertEqual(session_cache.get_current_user(HOST), LOGIN_B)

        # Now set back HOST_A as the current host. It should now be the most recent.
        session_cache.set_current_user(HOST, LOGIN_A)
        self.assertEqual(session_cache.get_recent_users(HOST),
                         [LOGIN_A, LOGIN_B])
        self.assertEqual(session_cache.get_current_user(HOST), LOGIN_A)

        # Update the cache 10 times.
        n_users = ["login-%d" % i for i in range(10)]
        for user in n_users:
            session_cache.set_current_user(HOST, user)

        # We should now have users 9 down to 2 in the most recent list.
        most_recents = ["login-%d" % i for i in range(9, 1, -1)]

        self.assertEqual(session_cache.get_recent_users(HOST), most_recents)
예제 #2
0
    def test_recent_users(self):
        """
        Makes sure the recent hosts list is keep up to date.
        """
        HOST = "https://host.shotgunstudio.com"
        LOGIN_A = "login_a"
        LOGIN_B = "login_b"

        self._clear_site_yml(HOST)

        # Make sure the recent hosts is initially empty.
        self.assertEqual(session_cache.get_recent_users(HOST), [])

        # Set HOST_A as the current host.
        session_cache.set_current_user(HOST, LOGIN_A)
        self.assertEqual(session_cache.get_recent_users(HOST), [LOGIN_A])
        self.assertEqual(session_cache.get_current_user(HOST), LOGIN_A)

        # Then set HOST_B as the new current host.
        session_cache.set_current_user(HOST, LOGIN_B)
        self.assertEqual(session_cache.get_recent_users(HOST), [LOGIN_B, LOGIN_A])
        self.assertEqual(session_cache.get_current_user(HOST), LOGIN_B)

        # Now set back HOST_A as the current host. It should now be the most recent.
        session_cache.set_current_user(HOST, LOGIN_A)
        self.assertEqual(session_cache.get_recent_users(HOST), [LOGIN_A, LOGIN_B])
        self.assertEqual(session_cache.get_current_user(HOST), LOGIN_A)

        # Update the cache 10 times.
        n_users = ["login-%d" % i for i in range(10)]
        for user in n_users:
            session_cache.set_current_user(HOST, user)

        # We should now have users 9 down to 2 in the most recent list.
        most_recents = ["login-%d" % i for i in range(9, 1, -1)]

        self.assertEqual(session_cache.get_recent_users(HOST), most_recents)
예제 #3
0
    def test_recent_users_downgrade(self):
        """
        Ensures that if an older core updated the authentication file, which means
        recent_users has not been kept up to date, that the recent users list
        has the current_user at the front.
        """
        HOST = "https://host.shotgunstudio.com"
        self._write_site_yml(
            HOST,
            {"current_user": "******", "recent_users": ["older.user", "current.user"]}
        )

        self.assertEqual(
            session_cache.get_recent_users(HOST), ["current.user", "older.user"]
        )
    def test_recent_users_downgrade(self):
        """
        Ensures that if an older core updated the authentication file, which means
        recent_users has not been kept up to date, that the recent users list
        has the current_user at the front.
        """
        HOST = "https://host.shotgunstudio.com"
        self._write_site_yml(
            HOST, {
                "current_user": "******",
                "recent_users": ["older.user", "current.user"]
            })

        self.assertEqual(session_cache.get_recent_users(HOST),
                         ["current.user", "older.user"])
    def test_recent_users_upgrade(self):
        """
        Ensures that if we've just upgraded to the latest core that the current
        user is part of the recent users.
        """
        HOST = "https://host.shotgunstudio.com"

        # The recent_users array is not present in the authentication.yml
        # file, so make sure that the session cache reports the user as the
        # most recent.
        self._write_site_yml(HOST, {
            "current_user": "******",
            "users": []
        })

        self.assertEqual(session_cache.get_recent_users(HOST),
                         ["current.user"])
예제 #6
0
    def test_recent_users_upgrade(self):
        """
        Ensures that if we've just upgraded to the latest core that the current
        user is part of the recent users.
        """
        HOST = "https://host.shotgunstudio.com"

        # The recent_users array is not present in the authentication.yml
        # file, so make sure that the session cache reports the user as the
        # most recent.
        self._write_site_yml(
            HOST, {"current_user": "******", "users": []}
        )

        self.assertEqual(
            session_cache.get_recent_users(HOST),
            ["current.user"]
        )