本文整理汇总了Python中simple_virtuoso_migrate.main.Main类的典型用法代码示例。如果您正苦于以下问题:Python Main类的具体用法?Python Main怎么用?Python Main使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Main类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_it_should_accept_a_schema_version_option_if_current_version_is_a_file
def test_it_should_accept_a_schema_version_option_if_current_version_is_a_file(self, cli_mock, _execution_log_mock, simplevirtuosomigrate_mock, virtuoso_mock, execute_migrations_mock):
self.initial_config.update({"schema_version":"version", "file_migration":None})
main = Main(Config(self.initial_config))
main.execute()
expected_calls = [
call('\nStarting Virtuoso migration...', 'PINK', log_level_limit=1),
call('\nDone.\n', 'PINK', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
execute_migrations_mock.assert_called_with('sparql_up', 'sparql_down', 'current_file', 'version')
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:11,代码来源:main_test.py
示例2: test_it_should_migrate_db_if_create_migration_option_is_not_activated_by_user
def test_it_should_migrate_db_if_create_migration_option_is_not_activated_by_user(self, migrate_mock, _execution_log_mock):
config = Config(self.initial_config)
main = Main(config)
main.execute()
expected_calls = [
call('\nStarting Virtuoso migration...', 'PINK', log_level_limit=1),
call('\nDone.\n', 'PINK', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
self.assertEqual(1, migrate_mock.call_count)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:11,代码来源:main_test.py
示例3: test_it_should_use_virtuoso_class_to_get_migration_and_execute_changes
def test_it_should_use_virtuoso_class_to_get_migration_and_execute_changes(self, _execution_log_mock, virtuoso_mock):
main = Main(Config(self.initial_config))
main._execute_migrations("sparql_up line 1\nsparql_up line 2\nsparql_up line 3", "sparql_down line 1\nsparql_down line 2\nsparql_down line 3", "current_version", "destination_version")
expected_calls = [
call('- Current version is: current_version', 'GREEN', log_level_limit=1),
call('- Destination version is: destination_version', 'GREEN', log_level_limit=1),
call('\nStarting Migration!', log_level_limit=1),
call('===== executing =====', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
main.virtuoso.execute_change.assert_called_with("sparql_up line 1\nsparql_up line 2\nsparql_up line 3", "sparql_down line 1\nsparql_down line 2\nsparql_down line 3", execution_log=_execution_log_mock)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:11,代码来源:main_test.py
示例4: test_it_should_do_nothing_if_sparql_up_has_two_lines
def test_it_should_do_nothing_if_sparql_up_has_two_lines(self, _execution_log_mock, virtuoso_mock):
main = Main(Config(self.initial_config))
main._execute_migrations("sparql_up line 1\nsparql_up line 2", "sparql_down line 1\nsparql_down line 2", "current_version", "destination_version")
expected_calls = [
call('- Current version is: current_version', 'GREEN', log_level_limit=1),
call('- Destination version is: destination_version', 'GREEN', log_level_limit=1),
call('\nStarting Migration!', log_level_limit=1),
call('\nNothing to do.\n', 'PINK', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
self.assertEqual(0, main.virtuoso.execute_change.call_count)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:11,代码来源:main_test.py
示例5: test_it_should_log_executed_sparql_if_asked_to_show_sparql
def test_it_should_log_executed_sparql_if_asked_to_show_sparql(self, _execution_log_mock, virtuoso_mock):
self.initial_config.update({"show_sparql":True})
main = Main(Config(self.initial_config))
main._execute_migrations("sparql_up line 1\nsparql_up line 2\nsparql_up line 3", "sparql_down line 1\nsparql_down line 2\nsparql_down line 3", "current_version", "destination_version")
expected_calls = [
call('- Current version is: current_version', 'GREEN', log_level_limit=1),
call('- Destination version is: destination_version', 'GREEN', log_level_limit=1),
call('\nStarting Migration!', log_level_limit=1),
call('===== executing =====', log_level_limit=1),
call('__________ SPARQL statements executed __________', 'YELLOW', log_level_limit=1),
call('sparql_up line 1\nsparql_up line 2\nsparql_up line 3', 'YELLOW', log_level_limit=1),
call('_____________________________________________', 'YELLOW', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:14,代码来源:main_test.py
示例6: test_it_should_not_execute_any_sparql_if_asked_to_show_sparql_only
def test_it_should_not_execute_any_sparql_if_asked_to_show_sparql_only(self, _execution_log_mock, virtuoso_mock):
self.initial_config.update({"show_sparql_only":True})
main = Main(Config(self.initial_config))
main._execute_migrations("sparql_up line 1\nsparql_up line 2\nsparql_up line 3", "sparql_down line 1\nsparql_down line 2\nsparql_down line 3", "current_version", "destination_version")
expected_calls = [
call('- Current version is: current_version', 'GREEN', log_level_limit=1),
call('- Destination version is: destination_version', 'GREEN', log_level_limit=1),
call("\nWARNING: commands are not being executed ('--show_sparql_only' activated)", 'RED', log_level_limit=1),
call('__________ SPARQL statements executed __________', 'YELLOW', log_level_limit=1),
call('sparql_up line 1\nsparql_up line 2\nsparql_up line 3', 'YELLOW', log_level_limit=1),
call('_____________________________________________', 'YELLOW', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
self.assertEqual(0, main.virtuoso.execute_change.call_count)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:14,代码来源:main_test.py
示例7: test_it_should_not_accept_file_migration_option_if_current_version_is_already_a_file
def test_it_should_not_accept_file_migration_option_if_current_version_is_already_a_file(self, cli_mock, _execution_log_mock, virtuoso_mock, execute_migrations_mock):
self.initial_config.update({"file_migration":"migration"})
main = Main(Config(self.initial_config))
try:
main.execute()
except SystemExit:
pass
expected_calls = [
call('\nStarting Virtuoso migration...', 'PINK', log_level_limit=1),
call('- Current version is: current_file', 'GREEN', log_level_limit=1),
call('- Destination version is: migration', 'GREEN', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
cli_mock.assert_called_with("[ERROR] Can't execute migration FROM File TO File (TIP: version it using git --tag and then use -m)\n", 'RED')
self.assertEqual(0, execute_migrations_mock.call_count)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:16,代码来源:main_test.py
示例8: test_it_should_add_triples_if_the_database_is_not_empty_and_the_option_is_activated_by_the_user
def test_it_should_add_triples_if_the_database_is_not_empty_and_the_option_is_activated_by_the_user(self, run_isql_mock, current_version_mock, execute_change_mock, _execution_log_mock):
self.initial_config.update({'load_ttl':'new_triple.ttl', 'show_sparql_only':None})
main = Main(Config(self.initial_config))
main.execute()
expected_calls = [
call('\nStarting Virtuoso migration...', 'PINK', log_level_limit=1),
call("- TTL(s) to upload: ['new_triple.ttl']", 'GREEN', log_level_limit=1),
call('- Current version is: 0.1', 'GREEN', log_level_limit=1),
call('- Destination version is: 0.1', 'GREEN', log_level_limit=1),
call('\nStarting Migration!', log_level_limit=1),
call('===== executing =====', log_level_limit=1),
call('', log_level_limit=1),
call('\nDone.\n', 'PINK', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:16,代码来源:main_test.py
示例9: test_it_should_add_triples_if_the_database_is_not_empty_and_the_option_is_activated_by_the_user
def test_it_should_add_triples_if_the_database_is_not_empty_and_the_option_is_activated_by_the_user(self, current_version_mock, statements_mock, execute_change_mock, _execution_log_mock):
self.initial_config.update({'add_ttl':'new_triples', 'show_sparql_only':None})
main = Main(Config(self.initial_config))
main.execute()
expected_calls = [
call('\nStarting Virtuoso migration...', 'PINK', log_level_limit=1),
call('- TTL to insert is: new_triples', 'GREEN', log_level_limit=1),
call('- Current version is: 0.1', 'GREEN', log_level_limit=1),
call('- Destination version is: new_triples', 'GREEN', log_level_limit=1),
call('\nStarting Migration!', log_level_limit=1),
call('===== executing =====', log_level_limit=1),
call('\nDone.\n', 'PINK', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
statements_mock.assert_called_with('new_triples', '0.1', 'git')
execute_change_mock.assert_called_with('sparql_up', 'sparql_down', execution_log=_execution_log_mock)
开发者ID:icaromedeiros,项目名称:simple-virtuoso-migrate,代码行数:17,代码来源:main_test.py
示例10: test_it_should_not_add_triples_if_show_sparql_only_option_is_activated_by_the_user
def test_it_should_not_add_triples_if_show_sparql_only_option_is_activated_by_the_user(self, current_version_mock, execute_change_mock, _execution_log_mock):
self.initial_config.update({'load_ttl':'new_triple.ttl', 'show_sparql_only':True})
main = Main(Config(self.initial_config))
main.execute()
expected_calls = [
call('\nStarting Virtuoso migration...', 'PINK', log_level_limit=1),
call("- TTL(s) to upload: ['new_triple.ttl']", 'GREEN', log_level_limit=1),
# call('- Current version is: 0.1', 'GREEN', log_level_limit=1),
# call('- Destination version is: 0.1', 'GREEN', log_level_limit=1),
# call("\nWARNING: commands are not being executed ('--show_sparql_only' activated)", 'RED', log_level_limit=1),
# call('__________ SPARQL statements executed __________', 'YELLOW', log_level_limit=1),
# call('sparql_up', 'YELLOW', log_level_limit=1),
# call('_____________________________________________', 'YELLOW', log_level_limit=1),
call('\nDone.\n', 'PINK', log_level_limit=1)
]
self.assertEqual(expected_calls, _execution_log_mock.mock_calls)
self.assertEqual(0, execute_change_mock.call_count)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:18,代码来源:main_test.py
示例11: test_it_should_write_the_message_to_cli
def test_it_should_write_the_message_to_cli(self, cli_mock, log_mock, simplevirtuosomigrate_mock):
main = Main(config=Config(self.initial_config))
main._execution_log('message to log', color='RED', log_level_limit=1)
cli_mock.assert_called_with('message to log', 'RED')
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:5,代码来源:main_test.py
示例12: test_it_should_call_run_after_method_after_calling_execute
def test_it_should_call_run_after_method_after_calling_execute(self, load_triples_mock, run_after_mock, execution_log_mock):
self.initial_config.update({'load_ttl':'', 'run_after': 'some_script_name'})
main = Main(Config(self.initial_config))
main.execute()
self.assertEqual(execution_log_mock.call_count, 3)
run_after_mock.assert_called_with('some_script_name', None)
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:6,代码来源:main_test.py
示例13: test_should_exec_and_call_run_after_script
def test_should_exec_and_call_run_after_script(self, valid_version_mock, load_triples_mock, execution_log_mock):
self.initial_config.update({'load_ttl':'', 'run_after': 'tests/samples/validate_run_after.py'})
main = Main(Config(self.initial_config))
main.execute()
self.assertEqual(valid_version_mock.call_count, 2)
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:5,代码来源:main_test.py
示例14: test_it_should_get_destination_version_when_user_does_not_inform_a_specific_version
def test_it_should_get_destination_version_when_user_does_not_inform_a_specific_version(self, simplevirtuosomigrate_mock):
self.initial_config.update({"schema_version": None})
main = Main(Config(self.initial_config))
self.assertEqual("latest_version_available", main._get_destination_version())
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:4,代码来源:main_test.py
示例15: test_it_should_get_destination_version_when_user_informs_a_specific_version
def test_it_should_get_destination_version_when_user_informs_a_specific_version(self, simplevirtuosomigrate_mock):
self.initial_config.update({"schema_version": "20090214115300"})
main = Main(Config(self.initial_config))
self.assertEqual("20090214115300", main._get_destination_version())
main.virtuoso_migrate.check_if_version_exists.assert_called_with('20090214115300')
self.assertEqual(1, main.virtuoso_migrate.check_if_version_exists.call_count)
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:6,代码来源:main_test.py
示例16: test_it_should_get_current_and_destination_versions_and_execute_migrations
def test_it_should_get_current_and_destination_versions_and_execute_migrations(self, virtuoso_mock, _get_destination_version_mock, execute_migrations_mock):
main = Main(Config(self.initial_config))
main.execute()
execute_migrations_mock.assert_called_with('sparql_up', 'sparql_down', 'current_version', 'destination_version')
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:4,代码来源:main_test.py
示例17: test_exit_if_invalid_python_version
def test_exit_if_invalid_python_version(self, mock_sys_version_info):
self.assertFalse(Main._valid_version())
self.assertRaises(SystemExit, Main, None)
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:3,代码来源:main_test.py
示例18: test_should_exec_and_fail_with_invalid_after_script
def test_should_exec_and_fail_with_invalid_after_script(self, load_triples_mock, execution_log_mock):
self.initial_config.update({'load_ttl':'', 'run_after': 'tests/samples/invalid_run_after.py'})
main = Main(Config(self.initial_config))
main.execute()
execution_log_mock.mock_calls[-2].called_with('\nRun after script tests/samples/invalid_run_after.py does not have run_after() function .\n', 'PINK', 1)
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:5,代码来源:main_test.py
示例19: test_it_should_write_the_message_to_cli_using_default_color
def test_it_should_write_the_message_to_cli_using_default_color(self, cli_mock, log_mock, simplevirtuosomigrate_mock):
self.initial_config.update({'log_level': 3})
main = Main(config=Config(self.initial_config))
main._execution_log('message to log')
cli_mock.assert_called_with('message to log', 'CYAN')
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:6,代码来源:main_test.py
示例20: test_detect_invalid_python_version
def test_detect_invalid_python_version(self, mock_sys_version_info):
self.assertFalse(Main._valid_version())
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:2,代码来源:main_test.py
注:本文中的simple_virtuoso_migrate.main.Main类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论