Exemple #1
0
 def test_open(self):
     filename = tempfile.mktemp()
     # Create if config file does not exist
     config = TwitterConfig(filename)
     self.assertFalse(os.path.isfile(filename))
     # If the path is a directory?
     dirname = tempfile.mkdtemp()
     config = TwitterConfig(dirname)
     self.assertRaises(IOError, config.save)
     os.removedirs(dirname)
Exemple #2
0
 def test_set(self):
     config = TwitterConfig(self.filename)
     config.set('option', 'value')  # Save hello=world to general section
     config.set('name', 'tao', account='Tao')
     config.set('name', 'mian', account='Mian')
     self.assertEqual(config.config.items('general'), [('option', 'value')])
     self.assertEqual(config.config.items('Tao'), [('name', 'tao')])
     self.assertEqual(config.config.items('Mian'), [('name', 'mian')])
Exemple #3
0
 def test_save(self):
     config = TwitterConfig(self.filename)
     config.set('option', 'value')
     config.set('name', 'Tao', account='Tao')
     config.save()
     with open(self.filename) as fp:
         content = fp.read()
     self.assertTrue(content.find('general'))
     self.assertTrue(content.find('Tao'))
     self.assertTrue(content.find('name'))
Exemple #4
0
 def test_set(self):
     config = TwitterConfig(self.filename)
     config.set("option", "value")  # Save hello=world to general section
     config.set("name", "tao", account="Tao")
     config.set("name", "mian", account="Mian")
     self.assertEqual(config.config.items("general"), [("option", "value")])
     self.assertEqual(config.config.items("Tao"), [("name", "tao")])
     self.assertEqual(config.config.items("Mian"), [("name", "mian")])
Exemple #5
0
 def test_save(self):
     config = TwitterConfig(self.filename)
     config.set("option", "value")
     config.set("name", "Tao", account="Tao")
     config.save()
     with open(self.filename) as fp:
         content = fp.read()
     self.assertTrue(content.find("general"))
     self.assertTrue(content.find("Tao"))
     self.assertTrue(content.find("name"))
Exemple #6
0
 def test_list_account(self):
     config = TwitterConfig(self.filename)
     self.assertEqual(config.list_accounts(), [])
     config.set('option', 'value')
     config.set('option', 'value', account='Tao')
     self.assertEqual(config.list_accounts(), ['Tao'])
Exemple #7
0
 def test_remove_account(self):
     config = TwitterConfig(self.filename)
     config.set('option', 'value', account='Tao')
     config.remove_account('Tao')
Exemple #8
0
 def test_unset(self):
     config = TwitterConfig(self.filename)
     config.set('option', 'value')
     config.set('format', 'json', account='Tao')
     config.unset('format', account='Tao')
     config.unset('option')
     self.assertIsNone(config.get('format', account='Tao'))
     self.assertIsNone(config.get('option'))
Exemple #9
0
 def test_get(self):
     config = TwitterConfig(self.filename)
     config.set('option', 'value')
     config.set('format', 'json', account='Tao')
     self.assertEqual(config.get('option'), 'value')
     self.assertEqual(config.get('format', account='Tao'), 'json')
Exemple #10
0
 def test_list_account(self):
     config = TwitterConfig(self.filename)
     self.assertEqual(config.list_accounts(), [])
     config.set("option", "value")
     config.set("option", "value", account="Tao")
     self.assertEqual(config.list_accounts(), ["Tao"])
Exemple #11
0
 def test_remove_account(self):
     config = TwitterConfig(self.filename)
     config.set("option", "value", account="Tao")
     config.remove_account("Tao")
Exemple #12
0
 def test_unset(self):
     config = TwitterConfig(self.filename)
     config.set("option", "value")
     config.set("format", "json", account="Tao")
     config.unset("format", account="Tao")
     config.unset("option")
     self.assertIsNone(config.get("format", account="Tao"))
     self.assertIsNone(config.get("option"))
Exemple #13
0
 def test_get(self):
     config = TwitterConfig(self.filename)
     config.set("option", "value")
     config.set("format", "json", account="Tao")
     self.assertEqual(config.get("option"), "value")
     self.assertEqual(config.get("format", account="Tao"), "json")