def test_rsa_fail(self):
     httpretty.register_uri(httpretty.POST, 'https://steamcommunity.com/mobilelogin/getrsakey/',
                             body='{"success": false}',
                             content_type='application/json; charset=utf-8')
     swb = SteamWebBrowser('user', 'password')
     with self.assertRaises(SteamWebError):
         swb._get_rsa_key()
 def test_rsa_fail(self):
     httpretty.register_uri(
         httpretty.POST,
         'https://steamcommunity.com/mobilelogin/getrsakey/',
         body='{"success": false}',
         content_type='application/json; charset=utf-8')
     swb = SteamWebBrowser('user', 'password')
     with self.assertRaises(SteamWebError):
         swb._get_rsa_key()
    def test_appdata_path(self):
        ''' Test if appdata path is created '''
        appdata_paths = ('STEAMWEBROWSER_HOME', 'APPDATA', 'XDG_CONFIG_HOME',
                         'HOME')
        for key in appdata_paths:
            temp_dir = tempfile.mkdtemp()
            with mock.patch.dict('os.environ', {key: temp_dir}):
                # Remove all other keys from environ
                for a in appdata_paths:
                    if a != key and a in os.environ:
                        del os.environ[a]

                swb = SteamWebBrowser('user', 'password')
                self.assertTrue(os.path.isdir(swb.appdata_path))
                self.assertTrue(os.access(swb.appdata_path, os.W_OK))
 def test_not_logged_in(self):
     httpretty.register_uri(httpretty.HEAD, 'https://store.steampowered.com/login/',
                             status=200)
     swb = SteamWebBrowser('user', 'password')
     self.assertFalse(swb.logged_in())
 def test_not_logged_in(self):
     httpretty.register_uri(httpretty.HEAD,
                            'https://store.steampowered.com/login/',
                            status=200)
     swb = SteamWebBrowser('user', 'password')
     self.assertFalse(swb.logged_in())