Skip to content

Commit

Permalink
Merge branch 'master' into fix_2fa
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilPawel authored and KamilPawel committed Sep 19, 2023
2 parents a9fc576 + cab82b1 commit 91a059e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion cfl_common/common/migrations/0041_populate_gb_counties.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pgeocode
from django.db import migrations

from portal.helpers.organisation import sanitise_uk_postcode
from ..helpers.organisation import sanitise_uk_postcode


class Migration(migrations.Migration):
Expand Down
4 changes: 2 additions & 2 deletions cfl_common/common/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import pgeocode
import re
from datetime import timedelta
from uuid import uuid4

import pgeocode
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
from django_countries.fields import CountryField

from portal.helpers.organisation import sanitise_uk_postcode
from .helpers.organisation import sanitise_uk_postcode


class UserProfile(models.Model):
Expand Down
10 changes: 10 additions & 0 deletions cfl_common/common/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .utils.organisation import create_organisation_directly, join_teacher_to_organisation
from .utils.student import create_independent_student_directly
from .utils.teacher import signup_teacher_directly
from ..helpers.organisation import sanitise_uk_postcode


class TestModels(TestCase):
Expand Down Expand Up @@ -90,6 +91,15 @@ def test_school_postcode(self):

assert school.county == ""

def test_sanitise_uk_postcode(self):
postcode_with_space = "AL10 9NE"
postcode_without_space = "AL109UL"
invalid_postcode = "123"

assert sanitise_uk_postcode(postcode_with_space) == "AL10 9NE" # Check it stays the same
assert sanitise_uk_postcode(postcode_without_space) == "AL10 9UL" # Check a space is added
assert sanitise_uk_postcode(invalid_postcode) == "123" # Check nothing happens

def test_daily_activity_serializer(self):
daily_activity = DailyActivity()

Expand Down
2 changes: 1 addition & 1 deletion portal/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "6.36.1"
__version__ = "6.36.2"
10 changes: 0 additions & 10 deletions portal/tests/test_helper_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from unittest.mock import patch, Mock

from portal.helpers.password import is_password_pwned
from portal.helpers.organisation import sanitise_uk_postcode


class TestClass:
Expand All @@ -29,12 +28,3 @@ def test_is_password_pwned__status_code_not_200(self, mock_get):
# Assert
mock_get.assert_called_once_with(f"https://api.pwnedpasswords.com/range/{sha1_hash[:5]}")
assert not result

def test_sanitise_uk_postcode(self):
postcode_with_space = "AL10 9NE"
postcode_without_space = "AL109UL"
invalid_postcode = "123"

assert sanitise_uk_postcode(postcode_with_space) == "AL10 9NE" # Check it stays the same
assert sanitise_uk_postcode(postcode_without_space) == "AL10 9UL" # Check a space is added
assert sanitise_uk_postcode(invalid_postcode) == "123" # Check nothing happens

0 comments on commit 91a059e

Please sign in to comment.