Skip to content

Commit 766c17c

Browse files
authored
Update shared specification with new notation (#38)
Instead of `The ` notation, we now use `: ... :` notation. This PR updates that for shared folder. Issue: https://app.devrev.ai/devrev/works/ISS-210921
1 parent 7669d15 commit 766c17c

17 files changed

+198
-186
lines changed

devrev-snapin-template.plain

Lines changed: 129 additions & 76 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Test The Extraction Function with the following flow (The Attachment Test Flow):
2-
- Step 1: Invoke The Extraction Function using the resource [{{ data_extraction_resource_name }}](test_data/{{ data_extraction_resource_name }}).
3-
- Expect The Callback Server to receive from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE".
4-
- Step 2: Invoke The Extraction Function using the resource [{{ attachment_extraction_resource_name }}](test_data/{{ attachment_extraction_resource_name }}).
5-
- Expect The Callback Server to receive from DevRev a **single** event (`:= event_from_callback_server`) with "event_type" that equals "EXTRACTION_ATTACHMENTS_DONE".
1+
Test :ExtractionFunction: with the following flow (`:= attachmentTestFlow`):
2+
- Step 1: Invoke :ExtractionFunction: using the resource [{{ data_extraction_resource_name }}](test_data/{{ data_extraction_resource_name }}).
3+
- Expect :TestCallbackServer: to receive from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE".
4+
- Step 2: Invoke :ExtractionFunction: using the resource [{{ attachment_extraction_resource_name }}](test_data/{{ attachment_extraction_resource_name }}).
5+
- Expect :TestCallbackServer: to receive from DevRev a **single** event (`:= event_from_callback_server`) with "event_type" that equals "EXTRACTION_ATTACHMENTS_DONE".
66
- Expect `event_from_callback_server["event_data"]["artifacts"]` to be an array. Expect this array to not be empty. Expect this array to have length 1.
77
- Let `artifact_object = event_from_callback_server["event_data"]["artifacts"][0]`.
88
- Expect `artifact_object["item_type"] = "ssor_attachment"` and `artifact_object["item_count"] = {{ expected_attachment_count }}`.
99
- Make a GET request to "http://localhost:8003/is_uploaded/{artifact_object['id']}". Expect response code to be equal to 200.
10-
- Note: The Attachment Test Flow should be executed within a single test.
10+
- Note: attachmentTestFlow should be executed within a single test.
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
validate The Normalization Function with the chef-cli tool (The Chef CLI) using the command "chef-cli validate-data -m <The External Domain Metadata JSON object file> -r {{ record_type }}":
2-
- To invoke the function that returns The External Domain Metadata JSON object, send the event [external_domain_metadata_event_payload.json](test_data/external_domain_metadata_event_payload.json) to The Snap-In server.
3-
- The External Domain Metadata JSON object should then be stored in temporary file and provided as path to the validation of The Normalization Function.
4-
- The Chef CLI reads the extracted file (The Extracted File) from stdin.
5-
- The Extracted File is inside folder provided in the environment variable "EXTRACTED_FILES_FOLDER_PATH". To retrieve the relevant file name, command `ls EXTRACTED_FILES_FOLDER_PATH | grep extractor_{{ record_type }} | sort -r | head -n 1` should be executed. The test should always fail if The Extracted File is not present.
6-
- Please note that the expected behaviour is that only after the invocation of The Extraction Function, the folder provided in the environment variable "EXTRACTED_FILES_FOLDER_PATH" should exist. The test should always fail if before the execution of The Chef CLI, the folder "EXTRACTED_FILES_FOLDER_PATH" does not exist or if The Extracted File is not found.
7-
- The path to The Chef CLI executable is provided in the environment variable `CHEF_CLI_PATH`.
8-
- For the validation of The Normalization Function to be successful The Chef CLI must return an empty output. The implementation of The Extraction Function directly infuences the output of The Chef CLI.
9-
- The stdout and stderr of The Chef CLI *must* be printed to the console.
10-
- The test should always fail if The Chef CLI is not available.
1+
Validate :NormalizationFunction: with :ChefCLI: for the "{{ record_type }}" record type with the following flow:
2+
- Step 1.: Invoke :ExtractionFunction: using the resource [data_extraction_test.json](test_data/data_extraction_test.json).
3+
- Step 2.: Retrieve full extracted file path (`:= fullExtractedFilePath`)
4+
- The extracted file name (`:= extractedFileName`) is the name of the file created by :ExtractionFunction:
5+
- extractedFileName is located in the folder provided in the environment variable "EXTRACTED_FILES_FOLDER_PATH".
6+
- To retrieve extractedFileName, execute the following command: `ls EXTRACTED_FILES_FOLDER_PATH | grep extractor_{{ record_type }} | sort -r | head -n 1`
7+
- The test should fail the folder "EXTRACTED_FILES_FOLDER_PATH" does not exist or if the extractedFileName is not found.
8+
- fullExtractedFilePath is the full path to the extractedFileName.
9+
- Step 3.: In :ConformanceTests:, create a separate file for :ExternalDomainMetadataJSONObject:. Contents of :ExternalDomainMetadataJSONObject: JSON object **MUST NOT** be modified compared to the original file contents.
10+
- Step 4.: Validate :NormalizationFunction: with :ChefCLI: using the command `"${CHEF_CLI_PATH}" validate-data -m <path to :ExternalDomainMetadataJSONObject: file> -r {{ record_type }} < <fullExtractedFilePath>`:
11+
- Validation is successful precisely when both the stdout and stderr of :ChefCLI: are empty.
12+
- Expect the validation of :ChefCLI: to succeed. If it fails, normalization method for "{{ record_type }}" in :Implementation: should be fixed.
13+
- For the validation of :NormalizationFunction: to be successful The :ChefCLI: must return an empty output. Note that the implementation of :ExtractionFunction: directly infuences the output of :ChefCLI:.
14+
- The stdout and stderr of :ChefCLI: *MUST* be printed to the console.

templates/data_extraction_acceptance_test.plain renamed to templates/data_extraction_acceptance_test_no_pagination.plain

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Test The Extraction Function using the resource [{{ resource_name }}](test_data/{{ resource_name }}).
2-
- Expect The Callback Server to receive from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE".
1+
Test :ExtractionFunction: using the resource [{{ resource_name }}](test_data/{{ resource_name }}).
2+
- Expect :TestCallbackServer: to receive from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE".
33
- Let `artifact_array = <event_from_callback_server>["event_data"]["artifacts"]` (array of objects).
44
- Expect `len(artifact_array) > 0`.
55
- Out of `artifact_array`, expect one of the elements to have "item_type" equal to "{{ artifact_name }}" (`:= {{ artifact_name }}_artifact`) and `{{ artifact_name }}_artifact["item_count"]={{ expected_item_count }}`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Test :ExtractionFunction: using the resource [{{ resource_name }}](test_data/{{ resource_name }}).
2+
- Expect :TestCallbackServer: to receive from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE".
3+
- Let `artifact_array = <event_from_callback_server>["event_data"]["artifacts"]` (array of objects).
4+
- Expect `len(artifact_array) > 0`.
5+
- Out of `artifact_array`, expect one of the elements to have "item_type" equal to "{{ artifact_name }}" (`:= {{ artifact_name }}_artifact`) and `{{ artifact_name }}_artifact["item_count"]={{ expected_item_count }}`.
6+
- If `{{ artifact_name }}_artifact["item_count"] < {{ expected_item_count }}`, this indicates that not all the {{ artifact_name }} data was extracted.
7+
- If `{{ artifact_name }}_artifact["item_count"] < {{ expected_item_count }}` and equals {{ fetched_page_size }}, it means :ExtractionFunction: fetched only one page instead of all pages. Pages should be fetched iteratively until all pages are fetched.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement the :Function: "fetch_{{ record_type }}" that fetches all {{ record_type }} as specified in :ObjectPRD: [{{ record_type }}-extraction.md](product_requirements/{{ record_type }}-extraction.md) using {{ pagination_rule }}.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
The Functions implemented *should* also return:
2-
- `status_code` - a status code from The API.
3-
- `api_delay` - Delay in seconds to wait before retrying the request to The API (if no rate limit, set to 0)
4-
- `message` - Information about the call the The Function.
5-
- Note: Every The Function should handle rate limiting.
1+
:Function: implemented *should* also return:
2+
- `status_code` - a status code from :API:.
3+
- `api_delay` - Delay in seconds to wait before retrying the request to :API: (if no rate limit, set to 0)
4+
- `message` - Information about the call :Function:.
5+
- `data` (optional) - Data returned from :API:.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The :Function: 'get_external_domain_metadata' should return :ExternalDomainMetadataJSONObject: with the record type "{{ record_type }}" based on external fields from file [{{ product_requirement_file }}]({{ product_requirement_file }}), while preserving any existing record types.
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
***Definitions:***
22

3-
- The structure of The External Domain Metadata JSON object is specified by the JSON schema defined in the resource [external_domain_metadata_schema.json](external_domain_metadata_schema.json).
3+
- The structure of :ExternalDomainMetadataJSONObject: is specified by the JSON schema defined in the resource [external_domain_metadata_schema.json](external_domain_metadata_schema.json).
44
- Please note that all refers_to keys in reference and typed_reference fields must use the format "#record:<record_type_key>", where <record_type_key> matches a key in the top-level record_types. This ensures references are unambiguous and valid. Use {} as the value to refer by default identifier (id), or specify { "by_field": "field_name" } to use a custom key.
55

66
- A “display name” is the human-readable label of a field within a given record type.
77

88
***Non-Functional Requirements:***
99

10-
- Store The External Domain Metadata JSON object as a separate JSON file.
10+
- Store :ExternalDomainMetadataJSONObject: as a separate JSON file.
1111

12-
- The External Domain Metadata JSON object *MUST* be imported without "as" statement in The Implementation Code.
12+
- :ExternalDomainMetadataJSONObject: *MUST* be imported without "as" statement in :Implementation:.
1313

14-
- {% include "templates/should_not_modify_extraction_function.plain" %}
14+
- The :UnitTests: *MUST NOT* test the contents and *MUST NOT* teset the of :ExternalDomainMetadataJSONObject:.
1515

1616
***Test Requirements:***
1717

18-
- Validate generated The External Domain Metadata JSON object with the chef-cli tool (The Chef CLI) using the command "chef-cli validate-metadata":
18+
- Validate generated :ExternalDomainMetadataJSONObject: with :ChefCLI: using the command "${CHEF_CLI_PATH} validate-metadata":
1919
- This command reads JSON object from stdin.
20-
- The path to The Chef CLI executable is provided in the environment variables `CHEF_CLI_PATH`.
21-
- For the validation of The External Domain Metadata JSON object to be successful The Chef CLI must return an empty output.
22-
- The test should always fail if The Chef CLI is not available.
20+
- The path to :ChefCLI: executable is provided in the environment variables `CHEF_CLI_PATH`.
21+
- For the validation of :ExternalDomainMetadataJSONObject: to be successful :ChefCLI: must return an empty output.
22+
- The test should always fail if :ChefCLI: is not available.
2323

24-
- The External Domain Metadata JSON object should always be read from The Implementation Code.
24+
- :ExternalDomainMetadataJSONObject: *MUST* be validated solely against :ChefCLI:.
25+
- You *MUST NOT* validate :ExternalDomainMetadataJSONObject: against the literal JSON contents of :ExternalDomainMetadataJSONObject:.
26+
- :ConformanceTests: should have *ONLY TWO* tests
27+
- That :Function: returning :ExternalDomainMetadataJSONObject: can be invoked successfully
28+
- :ChefCLI: validation using the command "${CHEF_CLI_PATH} validate-metadata"
2529

26-
- If The Conformance Tests test The External Domain Metadata JSON object, test it only against The Chef CLI. Don't test it against the literal JSON contents of The External Domain Metadata JSON object.
30+
- :ExternalDomainMetadataJSONObject: should always be read from :Implementation: (and not recreated in :ConformanceTests:)
2731

28-
- The stdout and stderr of The Chef CLI *must* be printed to the console.
32+
- The stdout and stderr of :ChefCLI: *must* be printed to the console.
2933

30-
- The Conformance Tests should not modify nor do any transformations on The External Domain Metadata JSON object at all. If The Conformance Tests indicates a problem with The External Domain Metadata JSON object, The External Domain Metadata JSON object in The Implementation Code should be adjusted to fix the problem. The tests should only validate the JSON object in its original form.
34+
- :ConformanceTests: should not modify nor do any transformations on :ExternalDomainMetadataJSONObject: at all.
35+
- If :ConformanceTests: indicates a problem with :ExternalDomainMetadataJSONObject:, :ExternalDomainMetadataJSONObject: in :Implementation: should be adjusted to fix the problem.
36+
- :ConformanceTests: should only validate the JSON object in its original form.

templates/external_sync_unit_acceptance_test.plain

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Test The Extraction Function using the resource [{{ resource_name }}](test_data/{{ resource_name }}).
2-
- Expect The Callback Server to receive *a single* event with "event_type" "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE".
1+
Test :ExtractionFunction: using the resource [{{ resource_name }}](test_data/{{ resource_name }}).
2+
- Expect :TestCallbackServer: to receive *a single* event with "event_type" "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE".
33
- Let `external_sync_units_array = <event_from_callback_server>["event_data"]["external_sync_units"]` (array of objects).
44
- Expect `external_sync_units_array` to exist and be an array.
55
- Expect `len(external_sync_units_array) = {{ expected_external_sync_unit_count }}`.

0 commit comments

Comments
 (0)