Skip to content

Commit

Permalink
remove dup country and locale factories fixes mozilla#2374
Browse files Browse the repository at this point in the history
  • Loading branch information
tiftran committed Mar 15, 2020
1 parent 6c0ea8b commit 3107582
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 53 deletions.
21 changes: 0 additions & 21 deletions app/experimenter/base/tests/factories.py

This file was deleted.

1 change: 0 additions & 1 deletion app/experimenter/base/tests/test_initial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestInitialData(TestCase):

def test_load_locales_countries(self):
self.assertTrue(not Country.objects.exists())
self.assertTrue(not Locale.objects.exists())
Expand Down
5 changes: 0 additions & 5 deletions app/experimenter/experiments/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


class JSONField(forms.CharField):

def clean(self, value):
cleaned_value = super().clean(value)

Expand All @@ -37,7 +36,6 @@ def clean(self, value):


class DSIssueURLField(forms.URLField):

def clean(self, value):
cleaned_value = super().clean(value)

Expand All @@ -57,7 +55,6 @@ def clean(self, value):


class BugzillaURLField(forms.URLField):

def clean(self, value):
cleaned_value = super().clean(value)

Expand All @@ -73,7 +70,6 @@ def clean(self, value):


class ChangeLogMixin(object):

def __init__(self, request, *args, **kwargs):
self.request = request
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -236,7 +232,6 @@ def clean(self):


class CustomModelChoiceIterator(ModelChoiceIterator):

def __iter__(self):
yield (CustomModelMultipleChoiceField.ALL_KEY, self.field.all_label)
for choice in super().__iter__():
Expand Down
3 changes: 1 addition & 2 deletions app/experimenter/experiments/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
ExperimentOrderingForm,
)
from experimenter.experiments.models import Experiment
from experimenter.base.tests.factories import CountryFactory, LocaleFactory
from experimenter.experiments.tests.factories import ExperimentFactory, UserFactory
from experimenter.experiments.tests.factories import ExperimentFactory, UserFactory, CountryFactory, LocaleFactory
from experimenter.bugzilla.tests.mixins import MockBugzillaMixin
from experimenter.experiments.tests.mixins import MockTasksMixin, MockRequestMixin

Expand Down
29 changes: 5 additions & 24 deletions app/experimenter/experiments/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@
from django.urls import reverse
from django.utils import timezone

from experimenter.base.tests.factories import CountryFactory, LocaleFactory
from experimenter.experiments.forms import NormandyIdForm
from experimenter.experiments.models import Experiment, Country, Locale
from experimenter.experiments.tests.factories import ExperimentFactory
from experimenter.experiments.tests.factories import (
ExperimentFactory,
CountryFactory,
LocaleFactory,
)

from experimenter.experiments.tests.mixins import MockTasksMixin
from experimenter.openidc.tests.factories import UserFactory
from experimenter.experiments.views import ExperimentFormMixin, ExperimentOrderingForm


class TestExperimentListView(TestCase):

def test_list_view_lists_experiments_with_default_order_no_archived(self):
user_email = "user@example.com"

Expand Down Expand Up @@ -187,11 +189,8 @@ def test_list_view_total_experiments_count(self):


class TestExperimentFormMixin(TestCase):

def test_get_form_kwargs_adds_request(self):

class BaseTestView(object):

def __init__(self, request):
self.request = request

Expand All @@ -208,9 +207,7 @@ class TestView(ExperimentFormMixin, BaseTestView):

@mock.patch("experimenter.experiments.views.reverse")
def test_get_success_url_returns_next_url_if_action_is_continue(self, mock_reverse):

class BaseTestView(object):

def __init__(self, request, instance):
self.request = request
self.object = instance
Expand Down Expand Up @@ -238,9 +235,7 @@ def mock_reverser(url_name, *args, **kwargs):

@mock.patch("experimenter.experiments.views.reverse")
def test_get_success_url_returns_detail_url_if_action_is_empty(self, mock_reverse):

class BaseTestView(object):

def __init__(self, request, instance):
self.request = request
self.object = instance
Expand Down Expand Up @@ -268,7 +263,6 @@ def mock_reverser(url_name, *args, **kwargs):


class TestExperimentCreateView(TestCase):

def test_view_creates_experiment(self):
user = UserFactory.create()
user_email = user.email
Expand Down Expand Up @@ -319,7 +313,6 @@ def test_view_creates_experiment(self):
DS_ISSUE_HOST="https://jira.example.com/browse/",
)
class TestExperimentOverviewUpdateView(TestCase):

def test_view_saves_experiment(self):
user = UserFactory.create()
user_email = user.email
Expand Down Expand Up @@ -367,7 +360,6 @@ def test_view_saves_experiment(self):


class TestExperimentTimelinePopulationUpdateView(TestCase):

def test_get_view_returns_context(self):
user_email = "user@example.com"

Expand Down Expand Up @@ -451,7 +443,6 @@ def test_view_saves_experiment(self):


class TestExperimentDesignUpdateView(TestCase):

def test_page_loads(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create()
Expand All @@ -463,7 +454,6 @@ def test_page_loads(self):


class TestExperimentObjectivesUpdateView(TestCase):

def test_view_saves_experiment(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
Expand Down Expand Up @@ -497,7 +487,6 @@ def test_view_saves_experiment(self):


class TestExperimentRisksUpdateView(TestCase):

def test_view_saves_experiment(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
Expand Down Expand Up @@ -556,7 +545,6 @@ def test_view_saves_experiment(self):


class TestResultsUpdateView(TestCase):

def test_view_saves_experiment(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_COMPLETE)
Expand All @@ -580,7 +568,6 @@ def test_view_saves_experiment(self):


class TestExperimentDetailView(TestCase):

def test_view_renders_correctly(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
Expand Down Expand Up @@ -643,7 +630,6 @@ def test_includes_bound_normandy_id_form_if_GET_param_set(self):


class TestExperimentStatusUpdateView(MockTasksMixin, TestCase):

def test_view_updates_status_and_redirects(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
Expand Down Expand Up @@ -685,7 +671,6 @@ def test_view_redirects_on_failure(self):


class TestExperimentReviewUpdateView(TestCase):

def test_view_updates_reviews_and_redirects(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_REVIEW)
Expand Down Expand Up @@ -732,7 +717,6 @@ def test_view_updates_reviews_and_redirects(self):


class TestExperimentCommentCreateView(TestCase):

def test_view_creates_comment_redirects_to_detail_page(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_DRAFT)
Expand Down Expand Up @@ -779,7 +763,6 @@ def test_view_redirects_to_detail_page_when_form_is_invalid(self):


class TestExperimentArchiveUpdateView(MockTasksMixin, TestCase):

def test_view_flips_archive_bool_and_redirects(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create(archived=False)
Expand All @@ -802,7 +785,6 @@ def test_view_flips_archive_bool_and_redirects(self):


class TestExperimentSubscribedUpdateView(TestCase):

def test_view_flips_subscribed_bool_and_redirects(self):
user = UserFactory()
experiment = ExperimentFactory.create()
Expand All @@ -824,7 +806,6 @@ def test_view_flips_subscribed_bool_and_redirects(self):


class TestExperimentNormandyUpdateView(TestCase):

def test_valid_recipe_id_updates_experiment_status(self):
user_email = "user@example.com"
experiment = ExperimentFactory.create_with_status(Experiment.STATUS_SHIP)
Expand Down

0 comments on commit 3107582

Please sign in to comment.