|
5 | 5 | from typing import Any, Dict |
6 | 6 |
|
7 | 7 | import pytest |
| 8 | +import yaml |
8 | 9 |
|
9 | 10 |
|
10 | 11 | @pytest.fixture |
@@ -640,3 +641,239 @@ def expected_manifest_with_url_base_linked_definition_normalized() -> Dict[str, |
640 | 641 | }, |
641 | 642 | }, |
642 | 643 | } |
| 644 | + |
| 645 | + |
| 646 | +@pytest.fixture |
| 647 | +def manifest_with_linked_definitions_url_base_authenticator_abnormal_schemas() -> Dict[str, Any]: |
| 648 | + with open( |
| 649 | + "unit_tests/sources/declarative/parsers/resources/abnormal_schemas_manifest.yaml", |
| 650 | + "r", |
| 651 | + ) as file: |
| 652 | + return dict(yaml.safe_load(file)) |
| 653 | + |
| 654 | + |
| 655 | +@pytest.fixture |
| 656 | +def expected_manifest_with_linked_definitions_url_base_authenticator_normalized() -> Dict[str, Any]: |
| 657 | + return { |
| 658 | + "version": "6.44.0", |
| 659 | + "type": "DeclarativeSource", |
| 660 | + "check": {"type": "CheckStream", "stream_names": ["pokemon"]}, |
| 661 | + "definitions": { |
| 662 | + "linked": { |
| 663 | + "HttpRequester": { |
| 664 | + "url_base": "https://pokeapi.co/api/v1/", |
| 665 | + "authenticator": { |
| 666 | + "type": "ApiKeyAuthenticator", |
| 667 | + "api_token": '{{ config["api_key"] }}', |
| 668 | + "inject_into": { |
| 669 | + "type": "RequestOption", |
| 670 | + "field_name": "API_KEY", |
| 671 | + "inject_into": "header", |
| 672 | + }, |
| 673 | + }, |
| 674 | + } |
| 675 | + } |
| 676 | + }, |
| 677 | + "streams": [ |
| 678 | + { |
| 679 | + "type": "DeclarativeStream", |
| 680 | + "name": "pokemon", |
| 681 | + "retriever": { |
| 682 | + "type": "SimpleRetriever", |
| 683 | + "decoder": {"type": "JsonDecoder"}, |
| 684 | + "requester": { |
| 685 | + "type": "HttpRequester", |
| 686 | + "path": "pokemon", |
| 687 | + "url_base": { |
| 688 | + "$ref": "#/definitions/linked/HttpRequester/url_base", |
| 689 | + }, |
| 690 | + "http_method": "GET", |
| 691 | + "authenticator": { |
| 692 | + "$ref": "#/definitions/linked/HttpRequester/authenticator", |
| 693 | + }, |
| 694 | + }, |
| 695 | + "record_selector": { |
| 696 | + "type": "RecordSelector", |
| 697 | + "extractor": {"type": "DpathExtractor", "field_path": []}, |
| 698 | + }, |
| 699 | + }, |
| 700 | + "schema_loader": { |
| 701 | + "type": "InlineSchemaLoader", |
| 702 | + "schema": {"$ref": "#/schemas/pokemon"}, |
| 703 | + }, |
| 704 | + }, |
| 705 | + { |
| 706 | + "type": "DeclarativeStream", |
| 707 | + "name": "trainers", |
| 708 | + "retriever": { |
| 709 | + "type": "SimpleRetriever", |
| 710 | + "decoder": {"type": "JsonDecoder"}, |
| 711 | + "requester": { |
| 712 | + "type": "HttpRequester", |
| 713 | + "path": "pokemon", |
| 714 | + "url_base": { |
| 715 | + "$ref": "#/definitions/linked/HttpRequester/url_base", |
| 716 | + }, |
| 717 | + "http_method": "GET", |
| 718 | + "authenticator": { |
| 719 | + "$ref": "#/definitions/linked/HttpRequester/authenticator", |
| 720 | + }, |
| 721 | + }, |
| 722 | + "record_selector": { |
| 723 | + "type": "RecordSelector", |
| 724 | + "extractor": {"type": "DpathExtractor", "field_path": []}, |
| 725 | + }, |
| 726 | + }, |
| 727 | + "schema_loader": { |
| 728 | + "type": "InlineSchemaLoader", |
| 729 | + "schema": {"$ref": "#/schemas/trainers"}, |
| 730 | + }, |
| 731 | + }, |
| 732 | + { |
| 733 | + "type": "DeclarativeStream", |
| 734 | + "name": "items", |
| 735 | + "retriever": { |
| 736 | + "type": "SimpleRetriever", |
| 737 | + "decoder": {"type": "JsonDecoder"}, |
| 738 | + "requester": { |
| 739 | + "type": "HttpRequester", |
| 740 | + "path": "pokemon", |
| 741 | + "url_base": "https://pokeapi.co/api/v2/", |
| 742 | + "http_method": "GET", |
| 743 | + "authenticator": { |
| 744 | + "$ref": "#/definitions/linked/HttpRequester/authenticator" |
| 745 | + }, |
| 746 | + }, |
| 747 | + "record_selector": { |
| 748 | + "type": "RecordSelector", |
| 749 | + "extractor": {"type": "DpathExtractor", "field_path": []}, |
| 750 | + }, |
| 751 | + }, |
| 752 | + "schema_loader": { |
| 753 | + "type": "InlineSchemaLoader", |
| 754 | + "schema": {"$ref": "#/schemas/items"}, |
| 755 | + }, |
| 756 | + }, |
| 757 | + { |
| 758 | + "type": "DeclarativeStream", |
| 759 | + "name": "location", |
| 760 | + "retriever": { |
| 761 | + "type": "SimpleRetriever", |
| 762 | + "decoder": {"type": "JsonDecoder"}, |
| 763 | + "requester": { |
| 764 | + "type": "HttpRequester", |
| 765 | + "path": "location", |
| 766 | + "url_base": "https://pokeapi.co/api/v2/", |
| 767 | + "http_method": "GET", |
| 768 | + "authenticator": { |
| 769 | + "$ref": "#/definitions/linked/HttpRequester/authenticator" |
| 770 | + }, |
| 771 | + }, |
| 772 | + "record_selector": { |
| 773 | + "type": "RecordSelector", |
| 774 | + "extractor": {"type": "DpathExtractor", "field_path": []}, |
| 775 | + }, |
| 776 | + }, |
| 777 | + "schema_loader": { |
| 778 | + "type": "InlineSchemaLoader", |
| 779 | + "schema": {"$ref": "#/schemas/location"}, |
| 780 | + }, |
| 781 | + }, |
| 782 | + { |
| 783 | + "type": "DeclarativeStream", |
| 784 | + "name": "berries", |
| 785 | + "retriever": { |
| 786 | + "type": "SimpleRetriever", |
| 787 | + "decoder": {"type": "JsonDecoder"}, |
| 788 | + "requester": { |
| 789 | + "type": "HttpRequester", |
| 790 | + "path": "berries", |
| 791 | + "url_base": "https://pokeapi.co/api/v2/", |
| 792 | + "http_method": "GET", |
| 793 | + "authenticator": { |
| 794 | + "$ref": "#/definitions/linked/HttpRequester/authenticator" |
| 795 | + }, |
| 796 | + }, |
| 797 | + "record_selector": { |
| 798 | + "type": "RecordSelector", |
| 799 | + "extractor": {"type": "DpathExtractor", "field_path": []}, |
| 800 | + }, |
| 801 | + }, |
| 802 | + "schema_loader": { |
| 803 | + "type": "InlineSchemaLoader", |
| 804 | + "schema": {"$ref": "#/schemas/berries"}, |
| 805 | + }, |
| 806 | + }, |
| 807 | + ], |
| 808 | + "spec": { |
| 809 | + "type": "Spec", |
| 810 | + "connection_specification": { |
| 811 | + "type": "object", |
| 812 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 813 | + "required": ["api_key"], |
| 814 | + "properties": { |
| 815 | + "api_key": { |
| 816 | + "type": "string", |
| 817 | + "order": 0, |
| 818 | + "title": "API Key", |
| 819 | + "airbyte_secret": True, |
| 820 | + } |
| 821 | + }, |
| 822 | + "additionalProperties": True, |
| 823 | + }, |
| 824 | + }, |
| 825 | + "metadata": { |
| 826 | + "assist": {}, |
| 827 | + "testedStreams": { |
| 828 | + "berries": {"streamHash": None}, |
| 829 | + "pokemon": {"streamHash": None}, |
| 830 | + "location": {"streamHash": None}, |
| 831 | + "trainers": {"streamHash": "ca4ee51a2aaa2a53b9c0b91881a84ad621da575f"}, |
| 832 | + "items": {"streamHash": "12e624ecf47c6357c74c27d6a65c72e437b1534a"}, |
| 833 | + }, |
| 834 | + "autoImportSchema": {"berries": True, "pokemon": True, "location": True}, |
| 835 | + }, |
| 836 | + "schemas": { |
| 837 | + "berries": { |
| 838 | + "type": "object", |
| 839 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 840 | + "properties": { |
| 841 | + "name": {"type": "string"}, |
| 842 | + "berry_type": {"type": "integer"}, |
| 843 | + }, |
| 844 | + "additionalProperties": True, |
| 845 | + }, |
| 846 | + "pokemon": { |
| 847 | + "type": "object", |
| 848 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 849 | + "properties": { |
| 850 | + "name": {"type": "string"}, |
| 851 | + "pokemon_type": {"type": "integer"}, |
| 852 | + }, |
| 853 | + }, |
| 854 | + "location": { |
| 855 | + "type": "object", |
| 856 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 857 | + "properties": { |
| 858 | + "name": {"type": "string"}, |
| 859 | + "location_type": {"type": "string"}, |
| 860 | + }, |
| 861 | + }, |
| 862 | + "trainers": { |
| 863 | + "type": "object", |
| 864 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 865 | + "properties": { |
| 866 | + "name": {"type": "string"}, |
| 867 | + "pokemon_type": {"type": "integer"}, |
| 868 | + }, |
| 869 | + }, |
| 870 | + "items": { |
| 871 | + "type": "object", |
| 872 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 873 | + "properties": { |
| 874 | + "name": {"type": "string"}, |
| 875 | + "pokemon_type": {"type": "integer"}, |
| 876 | + }, |
| 877 | + }, |
| 878 | + }, |
| 879 | + } |
0 commit comments