Skip to content

Commit

Permalink
Fix django urls import (#343)
Browse files Browse the repository at this point in the history
* fixing deprecated import

* fix for django in python 2.7

* skip pymongo map_reduce test when testing on latest pymongo versions since the map_reduce functionality has been removed
  • Loading branch information
pdimitra authored Dec 8, 2021
1 parent 5b16895 commit 6245d48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/apps/app_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import time
import opentracing
import opentracing.ext.tags as ext
try:
from django.urls import re_path
except ImportError:
from django.conf.urls import url as re_path

from django.conf.urls import url
from django.http import HttpResponse, Http404

filepath, extension = os.path.splitext(__file__)
Expand Down Expand Up @@ -123,9 +126,9 @@ def complex(request):


urlpatterns = [
url(r'^$', index, name='index'),
url(r'^cause_error$', cause_error, name='cause_error'),
url(r'^another$', another),
url(r'^not_found$', not_found, name='not_found'),
url(r'^complex$', complex, name='complex')
re_path(r'^$', index, name='index'),
re_path(r'^cause_error$', cause_error, name='cause_error'),
re_path(r'^another$', another),
re_path(r'^not_found$', not_found, name='not_found'),
re_path(r'^complex$', complex, name='complex')
]
6 changes: 6 additions & 0 deletions tests/clients/test_pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import unittest
import logging
import pytest

from nose.tools import (assert_is_none, assert_is_not_none,
assert_false, assert_true, assert_list_equal)
Expand All @@ -18,6 +19,10 @@

logger = logging.getLogger(__name__)

pymongoversion = pytest.mark.skipif(
pymongo.version_tuple >= (4, 0), reason="map reduce is removed in pymongo 4.0"
)


class TestPyMongoTracer(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -169,6 +174,7 @@ def test_successful_aggregate_query(self):
payload = json.loads(db_span.data["mongo"]["json"])
assert_true({"$match": {"type": "string"}} in payload, db_span.data["mongo"]["json"])

@pymongoversion
def test_successful_map_reduce_query(self):
mapper = "function () { this.tags.forEach(function(z) { emit(z, 1); }); }"
reducer = "function (key, values) { return len(values); }"
Expand Down

0 comments on commit 6245d48

Please sign in to comment.