def test_it_should_stop_execution_when_an_invalid_key_is_requested(self):
     config_path = os.path.abspath('sample.conf')
     config = FileConfig(config_path)
     try:
         config.get('invalid_config')
         self.fail('it should not pass here')
     except Exception, e:
         self.assertEqual("invalid key ('invalid_config')", str(e))
 def test_it_should_read_config_file(self):
     config_path = os.path.abspath('sample.conf')
     config = FileConfig(config_path)
     self.assertEquals(config.get('database_host'), 'localhost')
     self.assertEquals(config.get('database_user'), 'root')
     self.assertEquals(config.get('database_password'), '')
     self.assertEquals(config.get('database_name'), 'migration_example')
     self.assertEquals(config.get("database_migrations_dir"), [os.path.abspath('example')])
     self.assertEquals(config.get('utc_timestamp'), True)
     self.assertEquals(config.get('run_after'), './some_dummy_action.py')
     self.assertEquals(config.get('run_after_params')['key'], 'value')
 def test_it_should_read_config_file(self):
     config_path = os.path.abspath('sample.conf')
     config = FileConfig(config_path)
     self.assertEquals(config.get('database_host'), 'localhost')
     self.assertEquals(config.get('database_user'), 'root')
     self.assertEquals(config.get('database_password'), '')
     self.assertEquals(config.get('database_name'), 'migration_example')
     self.assertEquals(config.get("database_migrations_dir"), [os.path.abspath('example')])
     self.assertEquals(config.get('utc_timestamp'), True)
Exemplo n.º 4
0
 def test_it_should_raise_error_if_has_an_invalid_dir_on_migrations_dir(self):
     self.config.update("database_migrations_dir", FileConfig._parse_migrations_dir('invalid_path_it_does_not_exist')[0])
     virtuoso_migrate = SimpleVirtuosoMigrate(self.config)
     self.assertRaisesWithMessage(Exception, "directory not found ('%s')" % os.path.abspath('invalid_path_it_does_not_exist'), virtuoso_migrate.get_all_migrations)
 def test_it_should_accept_a_configuration_file_without_migrations_dir_key(self):
     config_path = os.path.abspath('sample2.conf')
     config = FileConfig(config_path)
     self.assertEqual("no_migrations_dir_key", config.get('migrations_dir', "no_migrations_dir_key"))
 def test_it_should_get_any_database_custom_variable_using_environment(self):
     config_path = os.path.abspath('sample.conf')
     config = FileConfig(config_path, 'some_env')
     self.assertEqual('Other Value', config.get('database_any_custom_variable'))
     self.assertEqual('Value', config.get('database_other_custom_variable'))
 def test_it_should_get_any_database_custom_variable(self):
     config_path = os.path.abspath('sample.conf')
     config = FileConfig(config_path)
     self.assertEqual('Some Value', config.get('database_any_custom_variable'))
 def test_it_should_use_configuration_by_environment(self):
     config_path = os.path.abspath('sample.conf')
     config = FileConfig(config_path, "env1")
     self.assertEquals('migration_example_env1', config.get('database_name'))
     self.assertEquals('root', config.get('database_user'))