Esempio n. 1
0
    def test_no_settings(self, *unused_mocks):
        """
        Test the behaviour of the defaults manager when there are no settings.
        """
        instance = UserSettings._instance = Mock()
        instance.shotgun_proxy = None
        instance.default_site = self._CONFIG_HOST
        instance.default_login = self._CONFIG_USER
        instance.app_store_proxy = None

        dm = DefaultsManager()
        self.assertEqual(dm.get_host(), self._SESSION_CACHE_HOST)
        self.assertEqual(dm.get_login(), self._SESSION_CACHE_USER)
        self.assertIs(dm.get_http_proxy(), None)
Esempio n. 2
0
    def test_empty_session_cache(self, *unused_mocks):
        """
        Test the behaviour of the defaults manager when the cache is empty
        and the config file is set.
        """
        instance = UserSettings._instance = Mock()
        instance.shotgun_proxy = self._CONFIG_HTTP_PROXY
        instance.default_site = self._CONFIG_HOST
        instance.default_login = self._CONFIG_USER

        dm = DefaultsManager()
        self.assertEqual(dm.get_host(), self._CONFIG_HOST)
        self.assertEqual(dm.get_login(), self._CONFIG_USER)
        self.assertIs(dm.get_http_proxy(), self._CONFIG_HTTP_PROXY)
Esempio n. 3
0
    def test_no_settings(self, *unused_mocks):
        """
        Test the behaviour of the defaults manager when there are no settings.
        """
        instance = UserSettings._instance = Mock()
        instance.shotgun_proxy = None
        instance.default_site = self._CONFIG_HOST
        instance.default_login = self._CONFIG_USER
        instance.app_store_proxy = None

        dm = DefaultsManager()
        self.assertEqual(dm.get_host(), self._SESSION_CACHE_HOST)
        self.assertEqual(dm.get_login(), self._SESSION_CACHE_USER)
        self.assertIs(dm.get_http_proxy(), None)
Esempio n. 4
0
    def test_empty_session_cache(self, *unused_mocks):
        """
        Test the behaviour of the defaults manager when the cache is empty
        and the config file is set.
        """
        instance = UserSettings._instance = Mock()
        instance.shotgun_proxy = self._CONFIG_HTTP_PROXY
        instance.default_site = self._CONFIG_HOST
        instance.default_login = self._CONFIG_USER

        dm = DefaultsManager()
        self.assertEqual(dm.get_host(), self._CONFIG_HOST)
        self.assertEqual(dm.get_login(), self._CONFIG_USER)
        self.assertIs(dm.get_http_proxy(), self._CONFIG_HTTP_PROXY)
Esempio n. 5
0
    def test_with_system_settings(self, *unused_mocks):
        """
        Test the behaviour of the defaults manager when there are no settings.
        """
        # Mock user settings singleton.
        instance = UserSettings._instance = Mock()
        instance.shotgun_proxy = None
        instance.default_site = self._CONFIG_HOST
        instance.default_login = self._CONFIG_USER
        instance.app_store_proxy = None

        with patch("tank.util.system_settings.SystemSettings.http_proxy",
                   new_callable=PropertyMock,
                   return_value="192.168.10.1"):
            dm = DefaultsManager()
            self.assertIs(dm.get_http_proxy(), "192.168.10.1")
Esempio n. 6
0
    def test_with_system_settings(self, *unused_mocks):
        """
        Test the behaviour of the defaults manager when there are no settings.
        """
        # Mock user settings singleton.
        instance = UserSettings._instance = Mock()
        instance.shotgun_proxy = None
        instance.default_site = self._CONFIG_HOST
        instance.default_login = self._CONFIG_USER
        instance.app_store_proxy = None

        with patch(
            "tank.util.system_settings.SystemSettings.http_proxy",
            new_callable=PropertyMock,
            return_value="192.168.10.1"
        ):
            dm = DefaultsManager()
            self.assertIs(dm.get_http_proxy(), "192.168.10.1")
Esempio n. 7
0
 def test_fixed_host_on_init_overrides_everything(self, _):
     fixed_host = "https://my-custom-host.shotgunstudio.com"
     dm = DefaultsManager(fixed_host)
     self.assertEqual(dm.is_host_fixed(), True)
     self.assertEqual(dm.get_host(), fixed_host)
Esempio n. 8
0
 def test_fixed_host_on_init_overrides_everything(self, _):
     fixed_host = "https://my-custom-host.shotgunstudio.com"
     dm = DefaultsManager(fixed_host)
     self.assertEqual(dm.is_host_fixed(), True)
     self.assertEqual(dm.get_host(), fixed_host)
Esempio n. 9
0
 def test_no_current_host(self, _):
     """
     Makes sure the login is None when there is no host.
     """
     self.assertIsNone(DefaultsManager().get_login())