Esempio n. 1
0
 def _add_write_operation_to_queue(self, cli, write_fun, cmd_format_str,
                                   **kwargs_dict):
     cli.do_reset('')
     cli.do_allowaccess('test_subject_1 write')
     cli.do_allowaccess('test_subject_3 changePermission')
     cli.do_preferrep('preferred-mn-2')
     cli.do_blockrep('blocked-mn-1')
     cli.do_blockrep('blocked-mn-2')
     cli.do_numberrep('42')
     cli.do_set('authoritative-mn urn:node:myTestMN')
     cli.do_set('rights-holder test-rights-holder-subject')
     cli.do_set('format-id test-format-id')
     cli.do_set('cn-url {}'.format(d1_test.d1_test_case.MOCK_CN_BASE_URL))
     cli.do_set('mn-url {}'.format(d1_test.d1_test_case.MOCK_MN_BASE_URL))
     pid_str = 'test_pid_{}'.format(
         d1_test.instance_generator.random_data.random_3_words())
     with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
         tmp_file.write('sciobj_for_{}'.format(pid_str).encode('utf-8'))
     # Add a create task to the queue.
     kwargs_dict.update({
         'pid': pid_str,
         'tmp_file_path': tmp_file.name,
     })
     with d1_test.d1_test_case.capture_std():
         write_fun(cmd_format_str.format(**kwargs_dict))
     yield pid_str
     os.unlink(tmp_file.name)
Esempio n. 2
0
 def test_1240(self, cn_client_v2):
     """do_numberrep(): Sets preferred number of replicas"""
     cli = d1_cli.impl.cli.CLI()
     cli.do_reset('')
     cli.do_numberrep('42')
     received_num_replicas = cli._command_processor.get_session(
     ).get_replication_policy().get_number_of_replicas()
     assert received_num_replicas == 42
Esempio n. 3
0
 def test_1250(self, cn_client_v2):
     """do_clearrep(): Resets replication policy to default"""
     cli = d1_cli.impl.cli.CLI()
     cli.do_reset('')
     cli.do_preferrep('preferred-mn-1')
     cli.do_preferrep('preferred-mn-2')
     cli.do_blockrep('blocked-mn-1')
     cli.do_blockrep('blocked-mn-2')
     cli.do_numberrep('42')
     cli.do_clearrep('')
     preferred_mn_list = cli._command_processor.get_session(
     ).get_replication_policy().get_preferred()
     assert not preferred_mn_list
     blocked_mn_list = cli._command_processor.get_session(
     ).get_replication_policy().get_blocked()
     assert not blocked_mn_list