def check_is_wfs_build_correctly(self, query, wfs_expected, mocked_get, mocked_build_wfs_query ): def save_wfs_returned(*args, **kwargs): save_wfs_returned.wfs_returned = build_wfs_query(*args, **kwargs) return save_wfs_returned.wfs_returned mocked_build_wfs_query.side_effect = save_wfs_returned response_data = {"features": [ "I'm getting this 1"]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) graphqlwfs(request) self.assertEqual(wfs_expected, save_wfs_returned.wfs_returned)
def test_topographyTopographicArea_one_feature(self, mocked_get): response_data = {"features": ["I'm getting this"]} query = ' { topographyTopographicArea(first: 1) } ' expected_value = {'topographyTopographicArea': response_data["features"]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(result, expected_value)
def test_single_feature(self, mocked_get): response_data = {"features": ["I'm getting this"]} query = ' { hello(count: 2, propertyName: "Type", literal: "Education") } ' expected_value = {'hello': response_data["features"]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(result, expected_value)
def test_topographyTopographicArea_counter_negative(self, mocked_get): response_data = 'Error: First needs to be 0 or more' query = ' { topographyTopographicArea(first: -5) } ' expected_value = {'topographyTopographicArea': [response_data]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(result, expected_value)
def test_topographyTopographicArea_empty_filter_parameters(self, mocked_get): response_data = {"features": ["I'm getting this 1", "I'm getting this 2"]} query = ' { topographyTopographicArea(first: 2, theme: "", descriptiveGroup: " ") } ' expected_value = {'topographyTopographicArea': response_data["features"]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(result, expected_value)
def test_counter_negative(self, mocked_get): response_data = 'Error: Count needs to be 0 or more' query = ' { hello(count: -5, propertyName: "Type", literal: "Education") } ' expected_value = {'hello': [response_data]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(result, expected_value)
def test_empty_filter_parameters(self, mocked_get): response_data = {"features": ["I'm getting this 1", "I'm getting this 2", "I'm getting this also"]} query = ' { hello(count: 2, propertyName: "", literal: " ") } ' expected_value = {'hello': response_data["features"]} mocked_get.return_value = self.make_mocked_response(response_data) request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(result, expected_value)
def test_count_2_features(self): query = ' { hello(count: 2, propertyName: "Type", literal: "Education") } ' request = self.make_request(query) result = graphqlwfs(request) self.assertEqual(len(result["hello"]), 2)
def local(): return graphqlwfs(request)