예제 #1
0
 def test_flags(self):
     cpap_extraction.CONFIG = py_config.config()
     cpap_extraction.sys.argv = [
         "cpap_extraction.py", "-v", "-d", "inputfile.001",
         "--destination=output"
     ]
     input, output_path = cpap_extraction.setup_args()
     self.assertEqual(input, "inputfile.001")
     self.assertEqual(output_path, "output")
     self.assertTrue(cpap_extraction.CONFIG["Verbose"])
     self.assertTrue(cpap_extraction.CONFIG["Debug"])
예제 #2
0
 def test_contents(self):
     test_config = py_config.config()
     self.assertFalse("Debug" in test_config)
     self.assertFalse(test_config["Debug"])
     self.assertTrue("Debug" in test_config)
예제 #3
0
 def setup(self):
     test_config = py_config.config()
     test_config.update({"this": "that"})
     return test_config
예제 #4
0
 def test_wrong_filetype(self):
     test_config = py_config.config()
     with self.assertWarns(Warning):
         test_config.set_file_path("NotAJson.txt")
     self.assertEqual("NotAJson.txt", test_config.config_path)
예제 #5
0
 def test_local_config(self):
     test_config = py_config.config()
     with self.assertWarns(Warning):
         test_config.set_file_path("THISCONFIG.JSON")
     self.assertEqual("THISCONFIG.JSON", test_config.config_path)
예제 #6
0
 def test_default_value(self):
     test_config = py_config.config()
     test_config.set_file_path()
     expected = os.path.join("cpap_config.json")
     self.assertEqual(expected, test_config.config_path)
예제 #7
0
 def test_open_file_does_not_exist(self, mocked_os, mocked_file):
     test_config = py_config.config()
     with self.assertRaises(FileNotFoundError):
         test_config.load("invalid/somepath")
예제 #8
0
 def test_open_file_exists(self, mock_json, mocked_os, mocked_file):
     test_config = py_config.config()
     test_config.load('Any file')
     mocked_file.assert_called_once_with('Any file', 'r')