Exemplo n.º 1
0
 def test_raises_error_when_config_is_not_accessible(self):
     self.mock_os.access.return_value = False
     with self.assertRaises(Exception):
         open_config_file('gtg.conf')
Exemplo n.º 2
0
 def test_creates_config_folder_when_missing(self):
     self.mock_path.exists.return_value = False
     self.mock_path.dirname.return_value = 'config'
     open_config_file('config/gtg.conf')
     self.mock_os.makedirs.assert_called_once_with('config')
Exemplo n.º 3
0
 def test_creates_config_file_when_missing(self):
     self.mock_path.exists.side_effect = lambda name: name != 'gtg.conf'
     open_config_file('gtg.conf')
     self.mock_open.assert_called_with('gtg.conf', 'w')
Exemplo n.º 4
0
 def test_reads_configuration(self):
     open_config_file('gtg.conf')
     self.mock_parser.assert_called_once_with('gtg.conf')
Exemplo n.º 5
0
 def test_falls_back_when_there_is_config_error(self, mock_log):
     self.mock_parser.side_effect = configparser.Error()
     open_config_file('gtg.conf')
     self.mock_parser.assert_called_once_with('gtg.conf')
     self.assertTrue(mock_log.warning.called)
Exemplo n.º 6
0
 def test_raises_error_when_config_is_not_accessible(self):
     self.mock_os.access.return_value = False
     with self.assertRaises(Exception):
         open_config_file("gtg.conf")
Exemplo n.º 7
0
 def test_creates_config_file_when_missing(self):
     self.mock_path.exists.side_effect = lambda name: name != "gtg.conf"
     open_config_file("gtg.conf")
     self.mock_open.assert_called_with("gtg.conf", "w")
Exemplo n.º 8
0
 def test_creates_config_folder_when_missing(self):
     self.mock_path.exists.return_value = False
     self.mock_path.dirname.return_value = "config"
     open_config_file("config/gtg.conf")
     self.mock_os.makedirs.assert_called_once_with("config")
Exemplo n.º 9
0
 def test_falls_back_when_there_is_config_error(self, mock_log):
     self.mock_parser.side_effect = configparser.Error()
     open_config_file("gtg.conf")
     self.mock_parser.assert_called_once_with("gtg.conf")
     mock_log.warning.assert_called()
Exemplo n.º 10
0
 def test_reads_configuration(self):
     open_config_file("gtg.conf")
     self.mock_parser.assert_called_once_with("gtg.conf")