本文整理汇总了Python中simple_virtuoso_migrate.config.Config.put方法的典型用法代码示例。如果您正苦于以下问题:Python Config.put方法的具体用法?Python Config.put怎么用?Python Config.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simple_virtuoso_migrate.config.Config
的用法示例。
在下文中一共展示了Config.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_it_should_raise_exception_for_an_inexistent_config_value_without_specify_a_default_value
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_raise_exception_for_an_inexistent_config_value_without_specify_a_default_value(self):
config = Config()
config.put("some_key", "some_value")
try:
config.get("ANOTHER_KEY")
except Exception, e:
self.assertEqual("invalid key ('another_key')", str(e))
示例2: test_it_should_raise_exception_when_removing_an_inexistent_config_value
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_raise_exception_when_removing_an_inexistent_config_value(self):
config = Config()
config.put("some_key", "some_value")
try:
config.remove("ANOTHER_KEY")
except Exception, e:
self.assertEqual("invalid configuration key ('another_key')", str(e))
示例3: test_it_should_not_update_saved_config_values
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_not_update_saved_config_values(self):
config = Config()
config.put("some_key", "some_value")
try:
config.put("some_key", "another_value")
except Exception, e:
self.assertEqual("the configuration key 'some_key' already exists and you cannot override any configuration", str(e))
示例4: test_it_should_transform_keys_to_lower_case
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_transform_keys_to_lower_case(self):
config = Config()
config.put("sOmE_kEy", "original_value")
self.assertEqual("original_value", config.get("SoMe_KeY"))
config.update("sOMe_kEy", "new_value")
self.assertEqual("new_value", config.get("some_KEY"))
config.remove("SOME_KEY")
self.assertRaises(Exception, config.get, "sOMe_KEY")
示例5: Config
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_update_value_to_a_existing_key_keeping_original_value_if_new_value_is_none_false_or_empty_string(self):
config = Config()
config.put("some_key", "original_value")
config.update("some_key", None)
self.assertEqual("original_value", config.get("some_key"))
config.update("some_key", False)
self.assertEqual("original_value", config.get("some_key"))
config.update("some_key", "")
self.assertEqual("original_value", config.get("some_key"))
示例6: VirtuosoTest
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
class VirtuosoTest(BaseTest):
def setUp(self):
super(VirtuosoTest, self).setUp()
self.config = Config()
self.config.put("database_migrations_dir", ".")
self.config.put("database_ontology", "test.ttl")
self.config.put("database_graph", "test")
self.config.put("database_host", "localhost")
self.config.put("database_user", "user")
self.config.put("database_password", "password")
self.config.put("database_port", 9999)
self.config.put("database_endpoint", "endpoint")
self.config.put("host_user", "host-user")
self.config.put("host_password", "host-passwd")
self.config.put("virtuoso_dirs_allowed", "/tmp")
self.config.put("migration_graph", "http://example.com/")
create_file("test.ttl", "")
self.data_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example.com/John> rdf:type <http://example.com/Person>.
"""
create_file("data.ttl", self.data_ttl_content)
self.structure_01_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
"""
create_file("structure_01.ttl", self.structure_01_ttl_content)
self.structure_02_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
:RoleOnSoapOpera rdf:type owl:Class .
:role rdf:type owl:Class ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger
] .
"""
create_file("structure_02.ttl", self.structure_02_ttl_content)
self.structure_03_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
:RoleOnSoapOpera rdf:type owl:Class .
:role rdf:type owl:Class ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:minQualifiedCardinality "1111"^^xsd:nonNegativeInteger
] ,
[
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:maxQualifiedCardinality "3333"^^xsd:nonNegativeInteger
] .
"""
create_file("structure_03.ttl", self.structure_03_ttl_content)
self.structure_04_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#.........这里部分代码省略.........
示例7: test_it_should_remove_saved_config_values
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_remove_saved_config_values(self):
config = Config()
config.put("some_key", "some_value")
initial = str(config)
config.remove("some_key")
self.assertNotEqual(initial, str(config))
示例8: test_it_should_update_value_to_a_existing_key
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_update_value_to_a_existing_key(self):
config = Config()
config.put("some_key", "original_value")
config.update("some_key", "some_value")
self.assertEqual("some_value", config.get("some_key"))
示例9: test_it_should_accept_non_empty_string_and_false_as_default_value
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_accept_non_empty_string_and_false_as_default_value(self):
config = Config()
config.put("some_key", "some_value")
self.assertEqual(None, config.get("ANOTHER_KEY", None))
self.assertEqual("", config.get("ANOTHER_KEY", ""))
self.assertEqual(False, config.get("ANOTHER_KEY", False))
示例10: test_it_should_return_default_value_for_an_inexistent_config_value
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_return_default_value_for_an_inexistent_config_value(self):
config = Config()
config.put("some_key", "some_value")
self.assertEqual("default_value", config.get("another_key", "default_value"))
示例11: test_it_should_return_previous_saved_config_values
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
def test_it_should_return_previous_saved_config_values(self):
config = Config()
config.put("some_key", "some_value")
self.assertEqual("some_value", config.get("some_key"))
示例12: VirtuosoTest
# 需要导入模块: from simple_virtuoso_migrate.config import Config [as 别名]
# 或者: from simple_virtuoso_migrate.config.Config import put [as 别名]
class VirtuosoTest(BaseTest):
maxDiff = None
def setUp(self):
super(VirtuosoTest, self).setUp()
self.config = Config()
self.config.put("database_migrations_dir", ".")
self.config.put("database_ontology", "test.ttl")
self.config.put("database_graph", "test")
self.config.put("database_host", "localhost")
self.config.put("database_user", "user")
self.config.put("database_password", "password")
self.config.put("database_port", 9999)
self.config.put("database_endpoint", "endpoint")
self.config.put("host_user", "root")
self.config.put("host_password", "")
self.config.put("virtuoso_dirs_allowed", ".")
self.config.put("migration_graph", "http://example.com")
create_file("test.ttl", "")
self.data_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example.com/John> rdf:type <http://example.com/Person>.
"""
create_file("data.ttl", self.data_ttl_content)
self.structure_01_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
"""
create_file("structure_01.ttl", self.structure_01_ttl_content)
self.structure_02_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
:RoleOnSoapOpera rdf:type owl:Class .
:role rdf:type owl:Class ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger
]."""
create_file("structure_02.ttl", self.structure_02_ttl_content)
def tearDown(self):
super(VirtuosoTest, self).tearDown()
delete_files("*.ttl")
# @patch('subprocess.Popen', return_value=Mock(**{"communicate.return_value": ("out", "err")}))
# def test_it_should_use_popen_to_run_a_command(self, popen_mock):
# Virtuoso(self.config).command_call("echo 1")
# popen_mock.assert_called_with('echo 1', shell=True, stderr=-1, stdout=-1)
# def test_it_should_return_stdout_and_stderr(self):
# stdout, _ = Virtuoso(self.config).command_call("echo 'out'")
# _, stderr = Virtuoso(self.config).command_call("python -V")
#
# self.assertEqual('out\n', stdout)
# self.assertEqual('python', stderr.split(' ')[0].lower())
# @patch('simple_virtuoso_migrate.virtuoso.Virtuoso.command_call', return_value=('', ''))
# def test_it_should_use_isql_executable_to_connect_to_virtuoso(self, command_call_mock):
# virtuoso = Virtuoso(self.config)
# conn = virtuoso.connect()
# self.assertEqual('isql -U user -P password -H localhost -S 9999 < ', conn)
# command_call_mock.assert_called_with('echo "status();"| isql -U user -P password -H localhost -S 9999 ')
# @patch('simple_virtuoso_migrate.virtuoso.Virtuoso.command_call',
# return_value=('', 'some error'))
# def test_it_should_raise_error_if_isql_status_return_error(self, command_call_mock):
# virtuoso = Virtuoso(self.config)
# self.assertRaisesWithMessage(Exception, 'could not connect to virtuoso: some error', virtuoso.connect)
# @patch('simple_virtuoso_migrate.virtuoso.Utils.write_temporary_file',
# return_value='filename.ttl')
# @patch('simple_virtuoso_migrate.virtuoso.Virtuoso.command_call',
# return_value=('', ''))
#.........这里部分代码省略.........