def test_check_size_in_lazyLoad_and_no_lazyLoad(self): ks = file_stream('test/test.contd.conf') kon = from_stream(ks, False) ks1 = file_stream('test/test.contd.conf') kon1 = from_stream(ks1, True) self.assertEqual(len(kon) > 0, True) self.assertEqual(len(kon1) > 0, True) self.assertEqual(kon.is_empty(), False) self.assertEqual(kon1.is_empty(), False) self.assertEqual(len(kon1), len(kon1))
def test_escaping_and_unescaping_entries_and_save(self): ks = file_stream('test/test.config.ini') ks1 = file_stream('test/test.txt', ':', ',') kon = from_stream(ks) kon1 = from_stream(ks1) self.assertEqual(kon.get("Hobby"), "i don't know") self.assertEqual(kon1.get("Hobby"), kon.get("Hobby")) self.assertEqual(kon1.get("Hobby"), "i don't know") kon.save('test/test.config.ini') new_ks = file_stream('test/test.config.ini') new_kon = from_stream(new_ks, True) new_kon1 = from_file('test/test.txt', True, ':', ',') self.assertEqual(str(kon), str(kon)) self.assertEqual(str(kon1), str(kon1))
def test_contains_with_lazy_load(self): ks = file_stream('test/test.comment.inf') ks.set_comment_prefix("[") kon = from_stream(ks) self.assertEqual(kon.contains("File"), True) self.assertEqual(kon.contains("Project"), True) self.assertEqual(kon.contains("Author"), True)
def test_the_single_pair_commenting_in_string_stream_konfiger(self): ks = string_stream( 'Name:Adewale Azeez,//Project:konfiger,Date:April 24 2020', ':', ',') kon = from_stream(ks) for key, value in kon.entries(): self.assertNotEqual([key, value], "Project") self.assertEqual(len(kon), 2)
def test_invalid_argument_type_to_Konfiger_resolve(self): kstream = file_stream('test/test.comment.inf') kstream.set_comment_prefix("[") kon = from_stream(kstream) with self.assertRaises(TypeError) as context: kon.resolve(123) self.assertTrue( 'io.github.thecarisma.konfiger: Invalid argument, the parameter must be a class object found ' in str(context.exception))
def test_resolve_with_match_get_key_function(self): kstream = file_stream('test/test.comment.inf') kstream.set_comment_prefix("[") kon = from_stream(kstream) texts = Texts() kon.resolve(texts) self.assertEqual(texts.project, "konfiger") self.assertEqual(texts.Platform, "Cross Platform") self.assertEqual(texts.file, "test.comment.inf") self.assertEqual(texts.author, "Adewale Azeez")
def test_resolve_without_match_get_key_function(self): kstream = file_stream('test/test.comment.inf') kstream.set_comment_prefix("[") kon = from_stream(kstream) texts_flat = TextsFlat() kon.resolve(texts_flat) self.assertEqual(texts_flat.project, "") self.assertEqual(texts_flat.Platform, "Cross Platform") self.assertEqual(texts_flat.File, "test.comment.inf") self.assertEqual(texts_flat.author, "")
def test_read_multiline_entry_from_file_stream(self): ks = file_stream('test/test.contd.conf') kon = from_stream(ks) self.assertEqual( kon.get("ProgrammingLanguages").find( "Kotlin, NodeJS, Powershell, Python, Ring, Rust") > 0, True) self.assertEqual(kon.get("ProjectName"), "konfiger") self.assertNotEqual( kon.get("Description").endswith( " in other languages and off the Android platform."), False)
def test_resolve_with_changing_values_and_map_key_with_attach(self): kstream = file_stream('test/test.comment.inf') kstream.set_comment_prefix("[") kon = from_stream(kstream) texts = Texts() kon.attach(texts) self.assertNotEqual(texts.project, "konfiger") self.assertNotEqual(texts.Platform, "Cross Platform") self.assertNotEqual(texts.file, "test.comment.inf") self.assertNotEqual(texts.author, "Adewale Azeez") kon.put("Project", "konfiger-nodejs") kon.put("Platform", "Windows, Linux, Mac, Raspberry") kon.put("author", "Thecarisma") self.assertEqual(texts.project, "konfiger-nodejs") self.assertEqual("Windows" in texts.Platform, True) self.assertEqual("Linux" in texts.Platform, True) self.assertEqual("Mac" in texts.Platform, True) self.assertEqual("Raspberry" in texts.Platform, True) self.assertEqual(texts.author, "Thecarisma")
def test_detach_an_object_from_konfiger(self): kstream = file_stream('test/test.comment.inf') kstream.set_comment_prefix("[") kon = from_stream(kstream) texts = Texts() kon.resolve(texts) self.assertEqual(texts.project, "konfiger") self.assertEqual(texts.Platform, "Cross Platform") self.assertEqual(texts.file, "test.comment.inf") self.assertEqual(texts.author, "Adewale Azeez") self.assertEqual(texts, kon.detach()) kon.put("Project", "konfiger-nodejs") kon.put("Platform", "Windows, Linux, Mac, Raspberry") kon.put("author", "Thecarisma") self.assertNotEqual(texts.project, "konfiger-nodejs") self.assertNotEqual("Windows" in texts.Platform, True) self.assertNotEqual("Linux" in texts.Platform, True) self.assertNotEqual("Mac" in texts.Platform, True) self.assertNotEqual("Raspberry" in texts.Platform, True) self.assertNotEqual(texts.author, "Thecarisma")