Exemplo n.º 1
0
 def test_default(self):
     document_shared_examples(
         self.doc_structure, self.operation_model,
         'response = client.foo', self._examples)
     self.assert_contains_lines_in_order([
         "**Examples**",
         "Sample Description.",
         "::",
         "  response = client.foo(",
         "      # mahalo",
         "      aloha=[",
         "          'other',",
         "          {",
         "              'nested': 'fun!',",
         "          },",
         "      ],",
         "      foo='bar',",
         "  )",
         "  print(response)",
         "Expected Output:",
         "::",
         "  {",
         "      # Sample Comment",
         "      'foo': 'baz',",
         "      'ResponseMetadata': {",
         "          '...': '...',",
         "      },",
         "  }",
     ])
Exemplo n.º 2
0
 def test_default(self):
     document_shared_examples(
         self.doc_structure, self.operation_model,
         'response = client.foo', self._examples)
     self.assert_contains_lines_in_order([
         "**Examples**",
         "Sample Description.",
         "::",
         "  response = client.foo(",
         "      # mahalo",
         "      aloha=[",
         "          'other',",
         "          {",
         "              'nested': 'fun!',",
         "          },",
         "      ],",
         "      foo='bar',",
         "  )",
         "  print(response)",
         "Expected Output:",
         "::",
         "  {",
         "      # Sample Comment",
         "      'foo': 'baz',",
         "      'ResponseMetadata': {",
         "          '...': '...',",
         "      },",
         "  }",
     ])
Exemplo n.º 3
0
    def _add_model_driven_method(self, section, method_name):
        service_model = self._client.meta.service_model
        operation_name = self._client.meta.method_to_api_mapping[method_name]
        operation_model = service_model.operation_model(operation_name)

        example_prefix = 'response = client.%s' % method_name
        document_model_driven_method(
            section, method_name, operation_model,
            event_emitter=self._client.meta.events,
            method_description=operation_model.documentation,
            example_prefix=example_prefix,
        )

        # Add the shared examples
        shared_examples = self._shared_examples.get(operation_name)
        if shared_examples:
            document_shared_examples(
                section, operation_model, example_prefix, shared_examples)
Exemplo n.º 4
0
    def _add_model_driven_method(self, section, method_name):
        service_model = self._client.meta.service_model
        operation_name = self._client.meta.method_to_api_mapping[method_name]
        operation_model = service_model.operation_model(operation_name)

        example_prefix = 'response = client.%s' % method_name
        document_model_driven_method(
            section,
            method_name,
            operation_model,
            event_emitter=self._client.meta.events,
            method_description=operation_model.documentation,
            example_prefix=example_prefix,
        )

        # Add the shared examples
        shared_examples = self._shared_examples.get(operation_name)
        if shared_examples:
            document_shared_examples(section, operation_model, example_prefix,
                                     shared_examples)