Exemplo n.º 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."
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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."
Exemplo n.º 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'
Exemplo n.º 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)
Exemplo n.º 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: |')
Exemplo n.º 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!%#!#$#"')
Exemplo n.º 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: |'
        )
Exemplo n.º 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!%#!#$#"'
        )
Exemplo n.º 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'
Exemplo n.º 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)
Exemplo n.º 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."
Exemplo n.º 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."
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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']
Exemplo n.º 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)
Exemplo n.º 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']
Exemplo n.º 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)