Esempio n. 1
0
    def test_should_render_backup_rules_matched(self):
        self.assertTrue(DefaultWriter().render_backup_rules_matched(
            state='included',
            rules=backup_rules.flatten_matched(state='included',
                                               rules=mock_data.BACKUP_RULES)))

        self.assertTrue(DefaultWriter().render_backup_rules_matched(
            state='excluded',
            rules=backup_rules.flatten_matched(state='excluded',
                                               rules=mock_data.BACKUP_RULES)))
Esempio n. 2
0
def cli(ctx, verbose, insecure, json):
    """Stasis command-line client."""
    logging.basicConfig(
        format='[%(asctime)-15s] [%(levelname)s] [%(name)-5s]: %(message)s',
        level=logging.getLevelName(logging.DEBUG if verbose else logging.INFO)
    )

    if not verbose:
        # suppress warning as self-signed certs are unlikely to have a SAN
        urllib3.disable_warnings(urllib3.exceptions.SubjectAltNameWarning)
        # suppress logging warnings
        logging.getLogger("urllib3").setLevel(logging.ERROR)

    application_name = 'stasis-client'
    application_main_class = 'stasis.client.Main'
    config_file_name = 'client.conf'
    api_token_file_name = 'api-token'

    config = load_client_config(application_name=application_name, config_file_name=config_file_name)
    api_token = load_api_token(application_name=application_name, api_token_file_name=api_token_file_name)

    context = ctx.ensure_object(Context)
    context.api = create_client_api(config=config, api_token=api_token, insecure=insecure)
    context.init = create_init_api(config=config, insecure=insecure, client_api=context.api)
    context.service_binary = application_name
    context.service_main_class = application_main_class
    context.rendering = JsonWriter() if json else DefaultWriter()
Esempio n. 3
0
 def test_should_render_dataset_definitions(self):
     self.assertTrue(DefaultWriter().render_dataset_definitions(
         definitions=dataset_definitions.flatten(mock_data.DEFINITIONS)))
Esempio n. 4
0
 def test_should_render_user(self):
     self.assertTrue(DefaultWriter().render_user(user=mock_data.USER))
Esempio n. 5
0
 def test_should_render_configured_schedules(self):
     self.assertTrue(DefaultWriter().render_configured_schedules(
         configured_schedules=mock_data.SCHEDULES_CONFIGURED))
Esempio n. 6
0
 def test_should_render_public_schedules(self):
     self.assertTrue(DefaultWriter().render_public_schedules(
         public_schedules=mock_data.SCHEDULES_PUBLIC))
Esempio n. 7
0
 def test_should_render_operation_response(self):
     self.assertTrue(DefaultWriter().render_operation_response(
         response={
             'successful': True,
             'operation': 'test-operation'
         }))
Esempio n. 8
0
 def test_should_render_backup_rules_unmatched(self):
     self.assertTrue(DefaultWriter().render_backup_rules_unmatched(
         rules=backup_rules.flatten_unmatched(
             rules=mock_data.BACKUP_RULES)))
Esempio n. 9
0
 def test_should_render_operation_progress(self):
     self.assertTrue(DefaultWriter().render_operation_progress(
         progress=mock_data.OPERATION_PROGRESS[0]))
Esempio n. 10
0
 def test_should_render_operations(self):
     self.assertTrue(DefaultWriter().render_operations(
         operations=mock_data.ACTIVE_OPERATIONS))
Esempio n. 11
0
 def test_should_render_device_connections(self):
     self.assertTrue(DefaultWriter().render_device_connections(
         connections=mock_data.ACTIVE_CONNECTIONS))
Esempio n. 12
0
 def test_should_render_device(self):
     self.assertTrue(DefaultWriter().render_device(device=mock_data.DEVICE))
Esempio n. 13
0
 def test_should_render_dataset_metadata_search_result(self):
     self.assertTrue(DefaultWriter().render_dataset_metadata_search_result(
         search_result=dataset_metadata.flatten_search_result(
             mock_data.METADATA_SEARCH_RESULTS)))
Esempio n. 14
0
 def test_should_render_dataset_metadata_filesystem(self):
     self.assertTrue(DefaultWriter().render_dataset_metadata_filesystem(
         metadata=dataset_metadata.flatten_filesystem(
             str(uuid4()), mock_data.METADATA)))
Esempio n. 15
0
 def test_should_render_dataset_metadata_crates(self):
     self.assertTrue(DefaultWriter().render_dataset_metadata_crates(
         metadata=dataset_metadata.flatten_crates(mock_data.METADATA)))
Esempio n. 16
0
 def test_should_render_dataset_entries(self):
     self.assertTrue(DefaultWriter().render_dataset_entries(
         entries=dataset_entries.flatten(mock_data.ENTRIES)))