Esempio n. 1
0
 def test_default_content(self):
     with open(os.devnull, "w") as devnull:
         with contextlib.redirect_stdout(devnull):
             config = obsgit.read_config(self.config_filename)
     self.assertEqual(config["import"]["url"], "https://api.opensuse.org")
     self.assertEqual(config["import"]["username"], os.getlogin())
     self.assertEqual(config["import"]["password"], "password")
     self.assertEqual(config["export"]["url"], "https://api.opensuse.org")
     self.assertEqual(config["export"]["username"], os.getlogin())
     self.assertEqual(config["export"]["password"], "password")
     self.assertEqual(config["export"]["storage"],
                      f"home:{os.getlogin()}:storage/files")
Esempio n. 2
0
    def test_custom_content(self):
        with open(self.config_filename, "w") as f:
            f.write("""
[import]
url = https://api.import.com
username = user_import
password = passwd_import

[export]
url = https://api.export.com
username = user_export
password = passwd_export
storage = project:storage/files
""")
        config = obsgit.read_config(self.config_filename)
        self.assertEqual(config["import"]["url"], "https://api.import.com")
        self.assertEqual(config["import"]["username"], "user_import")
        self.assertEqual(config["import"]["password"], "passwd_import")
        self.assertEqual(config["export"]["url"], "https://api.export.com")
        self.assertEqual(config["export"]["username"], "user_export")
        self.assertEqual(config["export"]["password"], "passwd_export")
        self.assertEqual(config["export"]["storage"], f"project:storage/files")
Esempio n. 3
0
 def test_default_persmissions(self):
     with open(os.devnull, "w") as devnull:
         with contextlib.redirect_stdout(devnull):
             obsgit.read_config(self.config_filename)
     self.assertTrue(self.config_filename.exists())
     self.assertEqual(self.config_filename.stat().st_mode, 33152)