Skip to content

Commit

Permalink
Merge branch 'main' of github.com:e-valuation/evap into live-server-t…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
Kakadus committed Dec 2, 2024
2 parents 5e36381 + 9c1588a commit d182ee9
Show file tree
Hide file tree
Showing 20 changed files with 3,236 additions and 2,311 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
run: isort . --check --diff
- run: ls -laR evap/static/ts
- name: Check TypeScript formatting
run: npx prettier --list-different --loglevel debug 'evap/static/ts/**/*.ts'
run: npx prettier --list-different --log-level debug 'evap/static/ts/**/*.ts'

backup-process:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -170,3 +170,14 @@ jobs:
path: evap/static/css
- name: Run tests
run: xvfb-run --auto-servernum npx jest

macos-nix-build:
runs-on: macos-14
name: Build nix environment on MacOS
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/setup_evap
with:
start-db: true
10 changes: 5 additions & 5 deletions evap/evaluation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,18 +1660,18 @@ def is_empty(self):


class UserProfileManager(BaseUserManager):
def create_user(self, *, email, password=None, first_name=None, last_name=None):
user = self.model(email=self.normalize_email(email), first_name_given=first_name, last_name=last_name)
def create_user(self, *, email, password=None, first_name_given=None, last_name=None):
user = self.model(email=self.normalize_email(email), first_name_given=first_name_given, last_name=last_name)
validate_password(password, user=user)
user.set_password(password)
user.save()
return user

def create_superuser(self, *, email, password=None, first_name=None, last_name=None):
def create_superuser(self, *, email, password=None, first_name_given=None, last_name=None):
user = self.create_user(
password=password,
email=self.normalize_email(email),
first_name=first_name,
first_name_given=first_name_given,
last_name=last_name,
)
user.is_superuser = True
Expand Down Expand Up @@ -1791,7 +1791,7 @@ class Meta:
verbose_name_plural = _("users")

USERNAME_FIELD = "email"
REQUIRED_FIELDS: list[str] = []
REQUIRED_FIELDS: list[str] = ["first_name_given", "last_name"]

def __str__(self):
return self.full_name
Expand Down
21 changes: 20 additions & 1 deletion evap/evaluation/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@
from evap.tools import MonthAndDay


class TestCreateUserCommand(TestCase):
# Regression test for #2204 - createsuperuser failing due to misconfigured REQUIRED_FIELDS
def test_create_super_user(self):
management.call_command(
"createsuperuser",
"--no-input",
"--first_name_given",
"Tony",
"--last_name",
"Kuchenbuch",
"--email",
"[email protected]",
)

user = UserProfile.objects.get(email="[email protected]")
self.assertEqual(user.first_name_given, "Tony")
self.assertEqual(user.last_name, "Kuchenbuch")


class TestAnonymizeCommand(TestCase):
@classmethod
def setUpTestData(cls):
Expand Down Expand Up @@ -224,7 +243,7 @@ def test_scss_called_with_no_sass_installed(self, mock_subprocess_run):
management.call_command("scss")


class TestTsCommend(TestCase):
class TestTsCommand(TestCase):
def setUp(self):
self.ts_path = os.path.join(settings.STATICFILES_DIRS[0], "ts")

Expand Down
Loading

0 comments on commit d182ee9

Please sign in to comment.