vmesel/PyJobs

View on GitHub

Showing 73 of 76 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def generate_thumbnail_quiz(quiz):
font_path = "{}Montserrat/Montserrat-Medium.ttf".format(
settings.THUMBNAILS_BASE_FOLDER
)
font_bold_path = "{}Montserrat/Montserrat-Bold.ttf".format(
Severity: Major
Found in pyjobs/core/utils.py and 1 other location - About 3 days to fix
pyjobs/core/utils.py on lines 7..53

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def generate_thumbnail(job):
font_path = "{}Montserrat/Montserrat-Medium.ttf".format(
settings.THUMBNAILS_BASE_FOLDER
)
font_bold_path = "{}Montserrat/Montserrat-Bold.ttf".format(
Severity: Major
Found in pyjobs/core/utils.py and 1 other location - About 3 days to fix
pyjobs/core/utils.py on lines 56..102

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@responses.activate
@patch("pyjobs.marketing.triggers.subscribe_user_to_mailer")
def test_valid_form(self, _mocked_subscription):
responses.add(
responses.POST,
Severity: Major
Found in pyjobs/core/tests/test_forms.py and 1 other location - About 1 day to fix
pyjobs/core/tests/test_forms.py on lines 133..163

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@responses.activate
@patch("pyjobs.marketing.triggers.subscribe_user_to_mailer")
def test_valid_form_but_without_mailer(self, _mocked_subscription):
responses.add(
responses.POST,
Severity: Major
Found in pyjobs/core/tests/test_forms.py and 1 other location - About 1 day to fix
pyjobs/core/tests/test_forms.py on lines 101..131

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def test_job_sharing_view_with_valid_form_data(self):
self.client.login(username="jacob", password="top_secret")
response = self.client.get("/job/{}/share/".format(self.job.unique_slug))
self.assertEqual(response.status_code, 200)
data = {"user_receiving_email": "testing@test.com"}
Severity: Major
Found in pyjobs/marketing/tests/test_sharing.py and 1 other location - About 1 day to fix
pyjobs/marketing/tests/test_sharing.py on lines 69..79

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def test_job_sharing_view_with_invalid_form_data(self):
self.client.login(username="jacob", password="top_secret")
response = self.client.get("/job/{}/share/".format(self.job.unique_slug))
self.assertEqual(response.status_code, 200)
data = {"user_receiving_email": "testing"}
Severity: Major
Found in pyjobs/marketing/tests/test_sharing.py and 1 other location - About 1 day to fix
pyjobs/marketing/tests/test_sharing.py on lines 81..91

File test_job_views.py has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from unittest.mock import patch
 
from django.contrib.auth.models import User
from django.http import HttpRequest
from django.test import Client, TestCase, override_settings
Severity: Major
Found in pyjobs/core/tests/test_job_views.py - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    @responses.activate
    def setUp(self):
    responses.add(
    responses.POST,
    "https://api.mailerlite.com/api/v2/subscribers",
    Severity: Major
    Found in pyjobs/marketing/tests/test_newsletter.py and 1 other location - About 5 hrs to fix
    pyjobs/core/tests/test_user_profile_model.py on lines 10..32

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    @responses.activate
    def setUp(self):
    responses.add(
    responses.POST,
    "https://api.mailerlite.com/api/v2/subscribers",
    Severity: Major
    Found in pyjobs/core/tests/test_user_profile_model.py and 1 other location - About 5 hrs to fix
    pyjobs/marketing/tests/test_newsletter.py on lines 16..37

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    @patch("pyjobs.marketing.triggers.send_group_notification")
    @patch("pyjobs.marketing.triggers.send_job_to_github_issues")
    @patch("pyjobs.marketing.triggers.post_telegram_channel")
    def setUp(
    self, _mocked_send_group_push, _mock_github, _mocked_post_telegram_channel
    Severity: Major
    Found in pyjobs/core/tests/test_views.py and 1 other location - About 4 hrs to fix
    pyjobs/core/tests/test_views.py on lines 60..76

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    @patch("pyjobs.marketing.triggers.send_group_notification")
    @patch("pyjobs.marketing.triggers.send_job_to_github_issues")
    @patch("pyjobs.marketing.triggers.post_telegram_channel")
    def setUp(
    self, _mocked_send_group_push, _mock_github, _mocked_post_telegram_channel
    Severity: Major
    Found in pyjobs/core/tests/test_views.py and 1 other location - About 4 hrs to fix
    pyjobs/core/tests/test_views.py on lines 14..30

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    @patch("pyjobs.core.views.EditProfileForm")
    def test_if_change_info_form_is_on_page_and_info_changed(self, _mocked_form):
    self.client.login(username="jacob", password="top_secret")
    response = self.client.post("/user/info/")
    content = response.content.decode("utf-8")
    Severity: Major
    Found in pyjobs/core/tests/test_views.py and 1 other location - About 3 hrs to fix
    pyjobs/core/tests/test_views.py on lines 138..143

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    @patch("pyjobs.core.views.PasswordChangeForm")
    def test_if_change_password_form_is_on_page_and_pass_changed(self, _mocked_form):
    self.client.login(username="jacob", password="top_secret")
    response = self.client.post("/user/password/")
    content = response.content.decode("utf-8")
    Severity: Major
    Found in pyjobs/core/tests/test_views.py and 1 other location - About 3 hrs to fix
    pyjobs/core/tests/test_views.py on lines 151..156

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def thumbnail_view(request, unique_slug):
    job = Job.objects.filter(unique_slug=unique_slug).first()
    im = generate_thumbnail(job=job)
     
    response = HttpResponse(content_type="image/png")
    Severity: Major
    Found in pyjobs/core/views.py and 1 other location - About 2 hrs to fix
    pyjobs/assessment/views.py on lines 90..96

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def quiz_thumbnail(request, unique_slug):
    quiz = Assessment.objects.filter(slug=unique_slug).first()
    im = generate_thumbnail_quiz(quiz=quiz)
     
    response = HttpResponse(content_type="image/png")
    Severity: Major
    Found in pyjobs/assessment/views.py and 1 other location - About 2 hrs to fix
    pyjobs/core/views.py on lines 563..569

    File test_job_model.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from datetime import datetime, timedelta
    from hashlib import sha512
    from unittest.mock import patch
    import responses
    from django.contrib.auth.models import User
    Severity: Minor
    Found in pyjobs/core/tests/test_job_model.py - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def test_if_change_password_form_is_on_page_and_validating(self):
      self.client.login(username="jacob", password="top_secret")
      response = self.client.post("/user/password/")
      content = response.content.decode("utf-8")
      self.assertIn("Por favor, corrija os erros abaixo", content)
      Severity: Major
      Found in pyjobs/core/tests/test_views.py and 1 other location - About 2 hrs to fix
      pyjobs/core/tests/test_views.py on lines 145..149

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def test_if_change_info_form_is_on_page_and_validating(self):
      self.client.login(username="jacob", password="top_secret")
      response = self.client.post("/user/info/")
      content = response.content.decode("utf-8")
      self.assertIn("Por favor, corrija os erros abaixo", content)
      Severity: Major
      Found in pyjobs/core/tests/test_views.py and 1 other location - About 2 hrs to fix
      pyjobs/core/tests/test_views.py on lines 132..136

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      if (subscription){
      postSubscribeObj('subscribe', subscription,
      function(response) {
      // Check the information is saved successfully into server
      if (response.status === 201) {
      Severity: Major
      Found in pyjobs/staticfiles/webpush/webpush.js and 1 other location - About 2 hrs to fix
      pyjobs/staticfiles/webpush/webpush.js on lines 106..117

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      function(subscription) {
      postSubscribeObj('subscribe', subscription,
      function(response) {
      // Check the information is saved successfully into server
      if (response.status === 201) {
      Severity: Major
      Found in pyjobs/staticfiles/webpush/webpush.js and 1 other location - About 2 hrs to fix
      pyjobs/staticfiles/webpush/webpush.js on lines 60..71
      Severity
      Category
      Status
      Source
      Language