def test1_get_download_info(self): api = Api() api.get_info = MagicMock() api.get_info.return_value = API_GET_INFO_TOONSTRUCK m_config.Config.get.return_value = "pl" exp = { 'id': 'installer_linux_en', 'name': 'Toonstruck', 'os': 'linux', 'language': 'en', 'language_full': 'English', 'version': 'gog-2', 'total_size': 963641344, 'files': [{ 'id': 'en3installer0', 'size': 963641344, 'downlink': 'https://api.gog.com/products/1207666633/downlink/installer/en3installer0' }] } obs = api.get_download_info("Test Game") self.assertEqual(exp, obs)
def test1_get_version(self): api = Api() game = MagicMock() game.platform = "linux" exp = "gog-2" obs = api.get_version(game, gameinfo=API_GET_INFO_TOONSTRUCK) self.assertEqual(exp, obs)
def test_get_download_file_md5(self): api = Api() api._Api__request = MagicMock() m_constants.SESSION.get.side_effect = MagicMock() m_constants.SESSION.get().text = '''<file name="gog_tis_100_2.0.0.3.sh" available="1" notavailablemsg="" md5="8acedf66c0d2986e7dee9af912b7df4f" chunks="4" timestamp="2015-07-30 17:11:12" total_size="36717998"> <chunk id="0" from="0" to="10485759" method="md5">7e62ce101221ccdae2e9bff5c16ed9e0</chunk> <chunk id="1" from="10485760" to="20971519" method="md5">b80960a2546ce647bffea87f85385535</chunk> <chunk id="2" from="20971520" to="31457279" method="md5">5464b4499cd4368bb83ea35f895d3560</chunk> <chunk id="3" from="31457280" to="36717997" method="md5">0261b9225fc10c407df083f6d254c47b</chunk> </file>''' exp = "8acedf66c0d2986e7dee9af912b7df4f" obs = api.get_download_file_md5("url") self.assertEqual(exp, obs)
def __init__(self, name="Minigalaxy"): current_locale = Config.get("locale") default_locale = locale.getdefaultlocale()[0] if current_locale == '': locale.setlocale(locale.LC_ALL, (default_locale, 'UTF-8')) else: try: locale.setlocale(locale.LC_ALL, (current_locale, 'UTF-8')) except NameError: locale.setlocale(locale.LC_ALL, (default_locale, 'UTF-8')) Gtk.ApplicationWindow.__init__(self, title=name) self.api = Api() self.search_string = "" self.offline = False # Set library self.library = Library(self, self.api) self.window_library.add(self.library) self.header_installed.set_active(Config.get("installed_filter")) # Set the icon icon = GdkPixbuf.Pixbuf.new_from_file(LOGO_IMAGE_PATH) self.set_default_icon_list([icon]) # Set theme settings = Gtk.Settings.get_default() if Config.get("use_dark_theme") is True: settings.set_property("gtk-application-prefer-dark-theme", True) else: settings.set_property("gtk-application-prefer-dark-theme", False) # Show the window if Config.get("keep_window_maximized"): self.maximize() self.show_all() # Create the thumbnails directory if not os.path.exists(THUMBNAIL_DIR): os.makedirs(THUMBNAIL_DIR, mode=0o755) # Interact with the API self.__authenticate() self.HeaderBar.set_subtitle(self.api.get_user_info()) self.sync_library()