예제 #1
0
파일: test_config.py 프로젝트: zdndanny/gtg
 def test_raises_an_error_when_no_value_and_no_default_value(
         self, mock_log):
     config = self.make_section_config({})
     section = SectionConfig('Name', config, {}, Mock())
     with self.assertRaises(ValueError):
         section.get('option')
     self.assertTrue(mock_log.warning.called)
예제 #2
0
 def test_warns_when_value_is_wrong_type(self, mock_log):
     config = self.make_section_config({'option': 'text'})
     section = SectionConfig('Name', config, {'option': 42}, Mock())
     value = section.get('option')
     self.assertTrue(mock_log.warning.called)
     # It should fall back to default value as 'text' is not an int
     self.assertEqual(42, value)
예제 #3
0
 def test_returns_empty_list_from_previous_empty_configuration(self):
     # Config from GTG 0.2.4
     config = self.make_section_config({
         'opened_tasks': ','})
     section = SectionConfig('Name', config, {'opened_tasks': []}, Mock())
     value = section.get('opened_tasks')
     self.assertEqual([], value)
예제 #4
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_warns_when_value_is_wrong_type(self, mock_log):
     config = self.make_section_config({"option": "text"})
     section = SectionConfig("Name", config, {"option": 42}, Mock())
     value = section.get("option")
     self.assertTrue(mock_log.warning.called)
     # It should fall back to default value as 'text' is not an int
     self.assertEqual(42, value)
예제 #5
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_returns_list_of_tuples(self):
     # Splitting only by ',' caused bugs
     #  - https://bugs.launchpad.net/gtg/+bug/1218093
     #  - https://bugs.launchpad.net/gtg/+bug/1216807
     config = self.make_section_config({"collapsed_tasks": "('0@1', '6@1'),('0@1', '8@1', '3@1', '5@1')"})
     section = SectionConfig("Name", config, {"collapsed_tasks": []}, Mock())
     value = section.get("collapsed_tasks")
     self.assertEqual(["('0@1', '6@1')", "('0@1', '8@1', '3@1', '5@1')"], value)
예제 #6
0
 def test_returns_list_of_tuples(self):
     # Splitting only by ',' caused bugs
     #  - https://bugs.launchpad.net/gtg/+bug/1218093
     #  - https://bugs.launchpad.net/gtg/+bug/1216807
     config = self.make_section_config(
         {'collapsed_tasks': "('0@1', '6@1'),('0@1', '8@1', '3@1', '5@1')"})
     section = SectionConfig('Name', config, {'collapsed_tasks': []},
                             Mock())
     value = section.get('collapsed_tasks')
     self.assertEqual(["('0@1', '6@1')", "('0@1', '8@1', '3@1', '5@1')"],
                      value)
예제 #7
0
 def test_warns_when_no_default_value_is_provided(self, mock_log):
     config = self.make_section_config({'option': '1'})
     section = SectionConfig('Name', config, {}, Mock())
     value = section.get('option')
     self.assertEqual('1', value)
예제 #8
0
 def test_returns_empty_list_for_empty_value(self):
     config = self.make_section_config({'option': ''})
     section = SectionConfig('Name', config, {'option': []}, Mock())
     value = section.get('option')
     self.assertEqual([], value)
예제 #9
0
 def test_returns_string_when_expected_string(self):
     config = self.make_section_config({'option': 'Hello'})
     section = SectionConfig('Name', config, {'option': 'World'}, Mock())
     value = section.get('option')
     self.assertEqual(str, type(value))
     self.assertEqual('Hello', value)
예제 #10
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_returns_bool_when_expected_bool(self):
     config = self.make_section_config({"option": "False"})
     section = SectionConfig("Name", config, {"option": False}, Mock())
     value = section.get("option")
     self.assertEqual(bool, type(value))
     self.assertEqual(False, value)
예제 #11
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_warns_when_no_default_value_is_provided(self, mock_log):
     config = self.make_section_config({"option": "1"})
     section = SectionConfig("Name", config, {}, Mock())
     value = section.get("option")
     self.assertTrue(mock_log.warning.called)
     self.assertEqual("1", value)
예제 #12
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_raises_an_error_when_no_value_and_no_default_value(self, mock_log):
     config = self.make_section_config({})
     section = SectionConfig("Name", config, {}, Mock())
     with self.assertRaises(ValueError):
         section.get("option")
     self.assertTrue(mock_log.warning.called)
예제 #13
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_returns_empty_list_from_previous_empty_configuration(self):
     # Config from GTG 0.2.4
     config = self.make_section_config({"opened_tasks": ","})
     section = SectionConfig("Name", config, {"opened_tasks": []}, Mock())
     value = section.get("opened_tasks")
     self.assertEqual([], value)
예제 #14
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_returns_empty_list_for_empty_value(self):
     config = self.make_section_config({"option": ""})
     section = SectionConfig("Name", config, {"option": []}, Mock())
     value = section.get("option")
     self.assertEqual([], value)
예제 #15
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_returns_string_when_expected_string(self):
     config = self.make_section_config({"option": "Hello"})
     section = SectionConfig("Name", config, {"option": "World"}, Mock())
     value = section.get("option")
     self.assertEqual(str, type(value))
     self.assertEqual("Hello", value)
예제 #16
0
 def test_returns_int_when_expected_int(self):
     config = self.make_section_config({'option': '42'})
     section = SectionConfig('Name', config, {'option': 42}, Mock())
     value = section.get('option')
     self.assertEqual(int, type(value))
     self.assertEqual(42, value)
예제 #17
0
 def test_returns_bool_when_expected_bool(self):
     config = self.make_section_config({'option': 'False'})
     section = SectionConfig('Name', config, {'option': False}, Mock())
     value = section.get('option')
     self.assertEqual(bool, type(value))
     self.assertEqual(False, value)
예제 #18
0
파일: test_config.py 프로젝트: abseabse/gtg
 def test_returns_int_when_expected_int(self):
     config = self.make_section_config({"option": "42"})
     section = SectionConfig("Name", config, {"option": 42}, Mock())
     value = section.get("option")
     self.assertEqual(int, type(value))
     self.assertEqual(42, value)