def test_invalid_data_does_not_validate(): extension = OrganizationExtension() with pytest.raises(ValidationError): validate_jsonschema({"organization": "2"}, extension.get_schema()) with pytest.raises(ValidationError): validate_jsonschema({"organization": 0}, extension.get_schema()) with pytest.raises(ValidationError): validate_jsonschema({"organization": [2]}, extension.get_schema())
def test_invalid_data_does_not_validate() -> None: extension = OrganizationExtension() schema = cast(MutableMapping[str, Any], extension.get_schema()) with pytest.raises(ValidationError): validate_jsonschema({"organization": "2"}, schema) with pytest.raises(ValidationError): validate_jsonschema({"organization": 0}, schema) with pytest.raises(ValidationError): validate_jsonschema({"organization": [2]}, schema)
def test_organization_extension_query_processing_happy_path(): extension = OrganizationExtension() raw_data = {"organization": 2} valid_data = validate_jsonschema(raw_data, extension.get_schema()) query = Query({"conditions": []}, TableSource("my_table", ColumnSet([]))) request_settings = HTTPRequestSettings() extension.get_processor().process_query(query, valid_data, request_settings) assert query.get_condition_from_ast() == binary_condition( None, ConditionFunctions.EQ, Column(None, None, "org_id"), Literal(None, 2))
def test_organization_extension_query_processing_happy_path() -> None: extension = OrganizationExtension() raw_data = {"organization": 2} valid_data = validate_jsonschema(raw_data, extension.get_schema()) query = Query({"conditions": []}, QueryEntity(EntityKey.EVENTS, ColumnSet([]))) request_settings = HTTPRequestSettings() extension.get_processor().process_query(query, valid_data, request_settings) assert query.get_condition_from_ast() == binary_condition( ConditionFunctions.EQ, Column("_snuba_org_id", None, "org_id"), Literal(None, 2))
def test_organization_extension_query_processing_happy_path(): extension = OrganizationExtension() raw_data = {"organization": 2} valid_data = validate_jsonschema(raw_data, extension.get_schema()) query = Query({"conditions": []}) request_settings = RequestSettings(turbo=False, consistent=False, debug=False) extension.get_processor().process_query(query, valid_data, request_settings) assert query.get_conditions() == [("org_id", "=", 2)]