Пример #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)