def test_register_empty_args(self, email, mock_request, request_json): request_json['source_owner_email'] = email mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == "Source owner email must be non-empty."
def test_register_invalid_avro_format(self, mock_request, request_json): request_json['schema'] = '{"type": "record", "name": "A"}' mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert "Invalid Avro schema JSON." in str(e.value)
def test_register_empty_src_name(self, src_name, mock_request, request_json): request_json['source'] = src_name mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == "Source name must be non-empty."
def test_register_invalid_numeric_src_name(self, mock_request, request_json): request_json['source'] = '12345' mock_request.json_body = request_json expected_exception = self.get_http_exception(400) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == 'Source or Namespace name should not be numeric'
def test_register_missing_doc_schema(self, mock_request, request_json, biz_schema_without_doc_json): request_json['schema'] = simplejson.dumps(biz_schema_without_doc_json) mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert "Missing `doc` " in str(e.value)
def test_register_invalid_namespace_name(self, mock_request, request_json): request_json['namespace'] = 'yelp|main' mock_request.json_body = request_json expected_exception = self.get_http_exception(400) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == ( 'Source name or Namespace name should not contain the ' 'restricted character: |')
def test_register_invalid_schema_json(self, mock_request, request_json): request_json['schema'] = 'Not valid json!%#!#$#' mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == ( 'Error "Expecting value: line 1 column 1 (char 0)" encountered ' 'decoding JSON: "Not valid json!%#!#$#"')
def test_register_invalid_namespace_name(self, mock_request, request_json): request_json['namespace'] = 'yelp|main' mock_request.json_body = request_json expected_exception = self.get_http_exception(400) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == ( 'Source name or Namespace name should not contain the ' 'restricted character: |' )
def test_register_invalid_schema_json(self, mock_request, request_json): request_json['schema'] = 'Not valid json!%#!#$#' mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == ( 'Error "Expecting value: line 1 column 1 (char 0)" encountered ' 'decoding JSON: "Not valid json!%#!#$#"' )
def test_register_invalid_numeric_src_name( self, mock_request, request_json ): request_json['source'] = '12345' mock_request.json_body = request_json expected_exception = self.get_http_exception(400) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == 'Source or Namespace name should not be numeric'
def test_register_missing_doc_schema( self, mock_request, request_json, biz_schema_without_doc_json ): request_json['schema'] = simplejson.dumps(biz_schema_without_doc_json) mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert "Missing `doc` " in str(e.value)
def test_register_empty_args( self, email, mock_request, request_json ): request_json['source_owner_email'] = email mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == "Source owner email must be non-empty."
def test_register_empty_src_name( self, src_name, mock_request, request_json ): request_json['source'] = src_name mock_request.json_body = request_json expected_exception = self.get_http_exception(422) with pytest.raises(expected_exception) as e: schema_views.register_schema(mock_request) assert e.value.code == expected_exception.code assert str(e.value) == "Source name must be non-empty."
def test_register_missing_doc_schema_NS_whitelisted( self, mock_request, request_json): request_json['schema'] = simplejson.dumps(self.biz_wl_schema_json) request_json['namespace'] = 'yelp_wl' mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def test_register_schema_defaults_to_datapipe_cluster_type( self, mock_request, request_json ): mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def test_register_schema_with_cluster_type( self, mock_request, request_json ): request_json['cluster_type'] = 'scribe' mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def test_register_missing_doc_schema_NS_whitelisted( self, mock_request, request_json ): request_json['schema'] = simplejson.dumps(self.biz_wl_schema_json) request_json['namespace'] = 'yelp_wl' mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def test_register_schema_with_cluster_type(self, mock_request, request_json): request_json['cluster_type'] = 'scribe' mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def test_register_schema_defaults_to_datapipe_cluster_type( self, mock_request, request_json): mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def test_create_schema_with_base_schema(self, mock_request, request_json): request_json['base_schema_id'] = 2 mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)
def new_biz_schema_id(self, mock_request, request_json): mock_request.json_body = request_json new_biz_schema = schema_views.register_schema(mock_request) return new_biz_schema['schema_id']
def test_register_schema(self, mock_request, request_json): mock_request.json_body = request_json actual = schema_views.register_schema(mock_request) self._assert_equal_schema_response(actual, request_json)