Skip to content

Commit

Permalink
reorganize imports with isort
Browse files Browse the repository at this point in the history
  • Loading branch information
ogiorgis committed Jan 9, 2025
1 parent 4cccf44 commit 09f2319
Show file tree
Hide file tree
Showing 110 changed files with 225 additions and 238 deletions.
7 changes: 1 addition & 6 deletions tests/autoclassify/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from mozlog.formatters.tbplformatter import TbplFormatter

from treeherder.model.models import (
FailureLine,
JobLog,
TextLogError,
TextLogErrorMetadata,
)
from treeherder.model.models import FailureLine, JobLog, TextLogError, TextLogErrorMetadata

test_line = {
"action": "test_result",
Expand Down
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
import os
import platform
import time
from os.path import join, dirname
from os.path import dirname, join
from unittest.mock import MagicMock
import yaml

import kombu
import moz_measure_noise
import pytest
import responses
import yaml
from _pytest.monkeypatch import MonkeyPatch
from django.conf import settings
from django.core.management import call_command
from rest_framework.test import APIClient
import moz_measure_noise

from tests.autoclassify.utils import test_line, create_failure_lines, create_text_log_errors
import treeherder.etl.bugzilla
from tests.autoclassify.utils import create_failure_lines, create_text_log_errors, test_line
from treeherder.etl.jobs import store_job_data
from treeherder.etl.push import store_push_data
from treeherder.model import models as th_models
Expand Down Expand Up @@ -365,6 +365,7 @@ def test_job_3(eleven_job_blobs, create_jobs):
@pytest.fixture
def mock_log_parser(monkeypatch):
from celery import shared_task

from treeherder.log_parser import tasks

@shared_task
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/test_job_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from tests.test_utils import add_log_response
from treeherder.etl.jobs import store_job_data

from treeherder.model.error_summary import get_error_summary
from treeherder.model.models import Job, JobLog, TextLogError

Expand Down
3 changes: 1 addition & 2 deletions tests/etl/test_bugzilla.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest

from django.urls import reverse

from treeherder.etl.bugzilla import BzApiBugProcess
from treeherder.model.models import Bugscache, BugJobMap
from treeherder.model.models import BugJobMap, Bugscache


@pytest.mark.django_db(transaction=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/etl/test_classification_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import datetime
import json

from requests.models import HTTPError
import pytest
import responses
from requests.models import HTTPError

from treeherder.etl.artifact import store_job_artifacts
from treeherder.etl.classification_loader import ClassificationLoader
Expand Down
2 changes: 1 addition & 1 deletion tests/etl/test_job_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import pytest
import responses
import slugid
from django.core.exceptions import ObjectDoesNotExist

from treeherder.etl.job_loader import JobLoader
from treeherder.etl.taskcluster_pulse.handler import handle_message
from treeherder.model.models import Job, JobLog, TaskclusterMetadata
from django.core.exceptions import ObjectDoesNotExist


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/etl/test_load_artifacts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json

from treeherder.etl.artifact import store_job_artifacts
from treeherder.model.models import TextLogError
from treeherder.model.error_summary import get_error_summary
from treeherder.model.models import TextLogError


def test_load_textlog_summary_twice(test_repository, test_job):
Expand Down
1 change: 0 additions & 1 deletion tests/etl/test_perf_data_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import time

import pytest

from django.core.management import call_command
from django.db import IntegrityError

Expand Down
4 changes: 2 additions & 2 deletions tests/log_parser/test_store_failure_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from requests.exceptions import HTTPError

from treeherder.log_parser.failureline import (
get_group_results,
store_failure_lines,
write_failure_lines,
get_group_results,
)
from treeherder.model.models import FailureLine, Group, JobLog, GroupStatus
from treeherder.model.models import FailureLine, Group, GroupStatus, JobLog

from ..sampledata import SampleData

Expand Down
7 changes: 4 additions & 3 deletions tests/log_parser/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest
from unittest.mock import patch

import pytest

from tests.test_utils import add_log_response
from treeherder.etl.jobs import store_job_data
from treeherder.etl.push import store_push_data
from treeherder.model.error_summary import get_error_summary, bug_suggestions_line
from treeherder.model.models import Job, TextLogError, Bugscache
from treeherder.model.error_summary import bug_suggestions_line, get_error_summary
from treeherder.model.models import Bugscache, Job, TextLogError

from ..sampledata import SampleData

Expand Down
21 changes: 9 additions & 12 deletions tests/model/cycle_data/test_perfherder_cycling.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import math
from datetime import datetime, timedelta
from unittest.mock import MagicMock
from unittest.mock import patch
from unittest.mock import MagicMock, patch

import pytest
from django.core.management import call_command
from django.db import connection, IntegrityError
from django.db import IntegrityError, connection

from treeherder.model.data_cycling import MaxRuntime
from treeherder.model.data_cycling import PerfherderCycler
from treeherder.model.data_cycling import PublicSignatureRemover
from treeherder.model.data_cycling import MaxRuntime, PerfherderCycler, PublicSignatureRemover
from treeherder.model.data_cycling.removal_strategies import (
MainRemovalStrategy,
TryDataRemoval,
IrrelevantDataRemoval,
MainRemovalStrategy,
StalledDataRemoval,
TryDataRemoval,
)
from treeherder.model.models import Push
from treeherder.perf.exceptions import MaxRuntimeExceededError
from treeherder.perf.models import (
BackfillReport,
MultiCommitDatum,
PerformanceAlert,
PerformanceAlertSummary,
PerformanceDatum,
PerformanceDatumReplicate,
PerformanceSignature,
PerformanceAlertSummary,
PerformanceAlert,
MultiCommitDatum,
BackfillReport,
)


Expand Down
2 changes: 1 addition & 1 deletion tests/model/cycle_data/test_treeherder_cycling.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from tests import test_utils
from tests.autoclassify.utils import create_failure_lines, test_line
from treeherder.model.models import Job, FailureLine, JobLog, JobType, Machine, JobGroup
from treeherder.model.models import FailureLine, Job, JobGroup, JobLog, JobType, Machine
from treeherder.perf.models import PerformanceDatum


Expand Down
2 changes: 1 addition & 1 deletion tests/model/test_files_bugzilla_map.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from treeherder.model.models import BugzillaComponent, FilesBugzillaMap, Repository
from treeherder.etl.files_bugzilla_map import FilesBugzillaMapProcess
from treeherder.model.models import BugzillaComponent, FilesBugzillaMap, Repository

EXPECTED_PROJECTS = [
"mozilla-central",
Expand Down
3 changes: 1 addition & 2 deletions tests/model/test_performance_tag.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
from django.db.utils import IntegrityError

from treeherder.perf.models import PerformanceTag

from django.db.utils import IntegrityError


def test_performance_tags_cannot_have_duplicate_names(transactional_db):
PerformanceTag.objects.create(name="harness")
Expand Down
8 changes: 4 additions & 4 deletions tests/perf/auto_perf_sheriffing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import taskcluster
from freezegun import freeze_time

from tests.conftest import SampleDataJSONLoader, create_perf_signature, create_perf_alert
from treeherder.model.models import MachinePlatform, Job, JobGroup, JobType
from tests.conftest import SampleDataJSONLoader, create_perf_alert, create_perf_signature
from treeherder.model.models import Job, JobGroup, JobType, MachinePlatform
from treeherder.perf.auto_perf_sheriffing.secretary import Secretary
from treeherder.perf.models import (
BackfillReport,
BackfillRecord,
BackfillReport,
PerformanceAlert,
PerformanceSettings,
PerformanceSignature,
PerformanceAlert,
)

# For testing Sherlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

from tests.conftest import create_perf_alert
from treeherder.model.models import Job, Option, OptionCollection, MachinePlatform
from treeherder.model.models import Job, MachinePlatform, Option, OptionCollection
from treeherder.perf.auto_perf_sheriffing.backfill_reports import AlertsPicker
from treeherder.perf.models import PerformanceAlert, PerformanceDatum, PerformanceSignature

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import random
import datetime
import random

from treeherder.perf.auto_perf_sheriffing.backfill_reports import (
BackfillReportMaintainer,
)
from treeherder.perf.models import (
BackfillRecord,
BackfillReport,
PerformanceAlert,
)
from treeherder.perf.auto_perf_sheriffing.backfill_reports import BackfillReportMaintainer
from treeherder.perf.models import BackfillRecord, BackfillReport, PerformanceAlert

EPOCH = datetime.datetime.utcfromtimestamp(0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import pytest

from .conftest import NON_RETRIGGERABLE_JOB_ID, ONE_DAY_INTERVAL
from treeherder.perf.auto_perf_sheriffing.backfill_reports import IdentifyAlertRetriggerables

from .conftest import NON_RETRIGGERABLE_JOB_ID, ONE_DAY_INTERVAL


# Unit tests
def test_identify_retriggerables_as_unit():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime, timedelta

import pytest
from tests import settings as test_settings
from django.core.management import call_command

from tests import settings as test_settings
from treeherder.perf.auto_perf_sheriffing.sherlock import Sherlock
from treeherder.perf.models import BackfillNotificationRecord
from treeherder.perf.exceptions import MaxRuntimeExceededError
from treeherder.perf.models import BackfillNotificationRecord

EPOCH = datetime.utcfromtimestamp(0)

Expand Down
5 changes: 2 additions & 3 deletions tests/perf/auto_perf_sheriffing/test_secretary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

import pytest
import simplejson as json

from django.db.models import Q

from treeherder.config.settings import IS_WINDOWS
from treeherder.perf.auto_perf_sheriffing.secretary import Secretary
from treeherder.model.models import Job, Push
from treeherder.perf.models import BackfillRecord, BackfillReport, PerformanceSettings
from treeherder.perf.auto_perf_sheriffing.outcome_checker import OutcomeChecker, OutcomeStatus
from treeherder.perf.auto_perf_sheriffing.secretary import Secretary
from treeherder.perf.models import BackfillRecord, BackfillReport, PerformanceSettings

# we're testing against this (automatically provided by fixtures)
JOB_TYPE_ID = 1
Expand Down
4 changes: 2 additions & 2 deletions tests/perf/auto_perf_sheriffing/test_sherlock.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import datetime, timedelta
import simplejson as json
from json import JSONDecodeError

import pytest
import simplejson as json
from django.db import models
from tests import settings as test_settings

from tests import settings as test_settings
from tests.perf.auto_perf_sheriffing.conftest import prepare_record_with_search_str
from treeherder.model.models import Job, Push
from treeherder.perf.auto_perf_sheriffing.sherlock import Sherlock
Expand Down
5 changes: 2 additions & 3 deletions tests/perf/auto_sheriffing_criteria/test_common_behaviour.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from collections.abc import Callable
from datetime import datetime, timedelta

import pytest
from django.conf import settings
from collections.abc import Callable

from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE
from treeherder.config.settings import BZ_DATETIME_FORMAT
from treeherder.perf.exceptions import NoFiledBugsError
from treeherder.perf.sheriffing_criteria import (
BugzillaFormula,
EngineerTractionFormula,
FixRatioFormula,
BugzillaFormula,
TotalAlertsFormula,
)


pytestmark = [pytest.mark.freeze_time(CASSETTES_RECORDING_DATE, tick=True)]


Expand Down
6 changes: 3 additions & 3 deletions tests/perf/auto_sheriffing_criteria/test_criteria_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
from dataclasses import replace
from datetime import timedelta
from itertools import chain
from unittest.mock import MagicMock
from dateutil.parser import parse as dateutil_parse
from multiprocessing.pool import AsyncResult
from unittest.mock import MagicMock

import pytest
from dateutil.parser import parse as dateutil_parse
from freezegun import freeze_time

from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE
from treeherder.perf.exceptions import NoFiledBugsError
from treeherder.perf.sheriffing_criteria import (
CriteriaRecord,
CriteriaTracker,
EngineerTractionFormula,
FixRatioFormula,
RecordComputer,
CriteriaRecord,
TotalAlertsFormula,
)
from treeherder.perf.sheriffing_criteria.criteria_tracking import ResultsChecker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import pytest
from datetime import datetime, timedelta

import pytest

from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE
from treeherder.config.settings import BZ_DATETIME_FORMAT
from treeherder.perf.sheriffing_criteria import EngineerTractionFormula


pytestmark = [pytest.mark.freeze_time(CASSETTES_RECORDING_DATE, tick=True)]


Expand Down
2 changes: 1 addition & 1 deletion tests/perfalert/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PerformanceDatum,
PerformanceSignature,
)
from treeherder.perf.utils import calculate_time_to, TRIAGE_DAYS, BUG_DAYS
from treeherder.perf.utils import BUG_DAYS, TRIAGE_DAYS, calculate_time_to


def _verify_alert(
Expand Down
3 changes: 2 additions & 1 deletion tests/push_health/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import datetime

import pytest
import responses

from treeherder.model.models import Push
Expand Down
Loading

0 comments on commit 09f2319

Please sign in to comment.