Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #861 from geometalab/feature/#845-merge-utils-pack…
Browse files Browse the repository at this point in the history
…ages

Feature/#845 merge utils packages
  • Loading branch information
hixi authored May 5, 2017
2 parents f6769f0 + fda015d commit 21458f4
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 21 deletions.
13 changes: 6 additions & 7 deletions osmaxx/excerptexport/forms/excerpt_form.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import json

from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.core.urlresolvers import reverse

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Field, Submit
from django import forms
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _

from .order_options_mixin import OrderOptionsMixin
from osmaxx.excerptexport.models import Excerpt, ExtractionOrder
from osmaxx.utilities.dict_helpers import select_keys
from osmaxx.utils.dict_helpers import select_keys
from .order_options_mixin import OrderOptionsMixin


class ExcerptForm(OrderOptionsMixin, forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion osmaxx/excerptexport/models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def update_is_overdue(self):
return (self.updated_at + EXTRACTION_PROCESSING_TIMEOUT_TIMEDELTA) < timezone.now()

def _handle_changed_status(self, *, incoming_request):
from osmaxx.utilities.shortcuts import Emissary
from osmaxx.utils.shortcuts import Emissary
emissary = Emissary(recipient=self.extraction_order.orderer)
status_changed_message = self._get_export_status_changed_message()
if self.status == self.FAILED:
Expand Down
2 changes: 1 addition & 1 deletion osmaxx/excerptexport/models/extraction_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_absolute_url(self):

def send_email_if_all_exports_done(self, incoming_request):
if all(export.is_status_final for export in self.exports.all()):
from osmaxx.utilities.shortcuts import Emissary
from osmaxx.utils.shortcuts import Emissary
emissary = Emissary(recipient=self.orderer)
emissary.inform_mail(
subject=self._get_all_exports_done_email_subject(),
Expand Down
2 changes: 1 addition & 1 deletion osmaxx/job_progress/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from osmaxx.api_client import ConversionApiClient
from osmaxx.conversion_api.statuses import FINAL_STATUSES, FAILED
from osmaxx.excerptexport.models import Export
from osmaxx.utilities.shortcuts import get_cached_or_set
from osmaxx.utils.shortcuts import get_cached_or_set

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion osmaxx/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ msgstr ""
msgid "Rest API"
msgstr ""

#: osmaxx/utilities/shortcuts.py:43
#: osmaxx/utils/shortcuts.py:43
msgid ""
"There is no email address assigned to your account. You won't be notified by "
"email!"
Expand Down
Empty file removed osmaxx/utilities/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions tests/excerptexport/models/test_plain_text_email_rendering.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.contrib.auth import get_user_model
from hamcrest import contains_string, match_equality

from osmaxx.excerptexport.models import ExtractionOrder, Excerpt
from osmaxx.utilities.shortcuts import Emissary

from hamcrest import contains_string, match_equality
from osmaxx.utils.shortcuts import Emissary


def test_send_email_if_all_exports_done_keeps_special_characters_unescaped(mocker, rf):
Expand Down
12 changes: 6 additions & 6 deletions tests/job_progress/test_job_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_calling_tracker_with_payload_indicating_started_updates_export_status(s
self.export.refresh_from_db()
self.assertEqual(self.export.status, STARTED)

@patch('osmaxx.utilities.shortcuts.Emissary')
@patch('osmaxx.utils.shortcuts.Emissary')
def test_calling_tracker_with_payload_indicating_queued_informs_user(
self, emissary_class_mock, *args, **mocks):
emissary_mock = emissary_class_mock()
Expand All @@ -103,7 +103,7 @@ def test_calling_tracker_with_payload_indicating_queued_informs_user(
)
)

@patch('osmaxx.utilities.shortcuts.Emissary')
@patch('osmaxx.utils.shortcuts.Emissary')
def test_calling_tracker_with_payload_indicating_started_informs_user(
self, emissary_class_mock, *args, **mocks):
emissary_mock = emissary_class_mock()
Expand All @@ -126,7 +126,7 @@ def test_calling_tracker_with_payload_indicating_started_informs_user(
)
)

@patch('osmaxx.utilities.shortcuts.Emissary')
@patch('osmaxx.utils.shortcuts.Emissary')
def test_calling_tracker_with_payload_indicating_failed_informs_user_with_error(
self, emissary_class_mock, *args, **mocks):
emissary_mock = emissary_class_mock()
Expand All @@ -149,7 +149,7 @@ def test_calling_tracker_with_payload_indicating_failed_informs_user_with_error(
)

@patch.object(Export, '_fetch_result_file')
@patch('osmaxx.utilities.shortcuts.Emissary')
@patch('osmaxx.utils.shortcuts.Emissary')
def test_calling_tracker_with_payload_indicating_finished_informs_user_with_success(
self, emissary_class_mock, *args, **mocks):
emissary_mock = emissary_class_mock()
Expand All @@ -171,7 +171,7 @@ def test_calling_tracker_with_payload_indicating_finished_informs_user_with_succ
)
)

@patch('osmaxx.utilities.shortcuts.Emissary')
@patch('osmaxx.utils.shortcuts.Emissary')
def test_calling_tracker_with_payload_indicating_unchanged_status_does_not_inform_user(
self, emissary_class_mock, *args, **mocks):
self.export.status = 'started'
Expand Down Expand Up @@ -222,7 +222,7 @@ def test_calling_tracker_with_payload_indicating_status_finished_downloads_resul

@requests_mock.Mocker(kw='requests')
@patch.object(ConversionApiClient, 'authorized_get', ConversionApiClient.get) # circumvent authorization logic
@patch('osmaxx.utilities.shortcuts.Emissary')
@patch('osmaxx.utils.shortcuts.Emissary')
def test_calling_tracker_with_payload_indicating_final_status_for_only_remaining_nonfinal_export_of_extraction_order_advertises_downloads(
self, emissary_class_mock, *args, **mocks):
self.export.conversion_service_job_id = 1
Expand Down
Empty file removed tests/utilities/__init__.py
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest.case import TestCase

from osmaxx.utilities.dict_helpers import are_all_keys_in
from osmaxx.utils.dict_helpers import are_all_keys_in


class AreAllKeysInTest(TestCase):
Expand Down

0 comments on commit 21458f4

Please sign in to comment.