Exemplo n.º 1
0
 def test1_verify_installer_integrity(self, mock_subprocess, mock_chmod,
                                      mock_is_file):
     mock_is_file.return_value = True
     mock_subprocess().returncode = 0
     game = Game("Beneath A Steel Sky",
                 install_dir="/home/makson/GOG Games/Beneath a Steel Sky")
     installer_path = "/home/makson/.cache/minigalaxy/download/Beneath a Steel Sky/beneath_a_steel_sky_en_gog_2_20150.sh"
     exp = ""
     obs = installer.verify_installer_integrity(game, installer_path)
     self.assertEqual(exp, obs)
Exemplo n.º 2
0
 def test1_verify_installer_integrity(self, mock_hash, mock_is_file):
     md5_sum = "5cc68247b61ba31e37e842fd04409d98"
     mock_is_file.return_value = True
     mock_hash().hexdigest.return_value = md5_sum
     game = Game("Beneath A Steel Sky",
                 install_dir="/home/makson/GOG Games/Beneath a Steel Sky",
                 md5sum=md5_sum)
     installer_path = "/home/user/.cache/minigalaxy/download/" \
                      "Beneath a Steel Sky/beneath_a_steel_sky_en_gog_2_20150.sh"
     exp = ""
     with patch("builtins.open", mock_open(read_data=b"")):
         obs = installer.verify_installer_integrity(game, installer_path)
     self.assertEqual(exp, obs)
Exemplo n.º 3
0
 def test2_verify_installer_integrity(self, mock_listdir, mock_hash, mock_is_file):
     md5_sum = "5cc68247b61ba31e37e842fd04409d98"
     installer_name = "beneath_a_steel_sky_en_gog_2_20150.sh"
     corrupted_md5_sum = "99999947b61ba31e37e842fd04409d98"
     mock_is_file.return_value = True
     mock_hash().hexdigest.return_value = corrupted_md5_sum
     mock_listdir.return_value = [installer_name]
     game = Game("Beneath A Steel Sky", install_dir="/home/makson/GOG Games/Beneath a Steel Sky",
                 md5sum={installer_name: md5_sum})
     installer_path = "/home/user/.cache/minigalaxy/download/" \
                      "Beneath a Steel Sky/{}".format(installer_name)
     exp = _("{} was corrupted. Please download it again.").format(installer_name)
     with patch("builtins.open", mock_open(read_data=b"aaaa")):
         obs = installer.verify_installer_integrity(game, installer_path)
     self.assertEqual(exp, obs)