示例#1
0
    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."
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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."
示例#5
0
    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'
示例#6
0
    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)
示例#7
0
    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: |')
示例#8
0
    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!%#!#$#"')
示例#9
0
    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: |'
        )
示例#10
0
    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!%#!#$#"'
        )
示例#11
0
    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'
示例#12
0
    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)
示例#13
0
    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."
示例#14
0
    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."
示例#15
0
 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)
示例#16
0
 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)
示例#17
0
 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)
示例#18
0
 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)
示例#19
0
 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)
示例#20
0
 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)
示例#21
0
 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)
示例#22
0
 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)
示例#23
0
 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']
示例#24
0
 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)
示例#25
0
 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']
示例#26
0
 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)