Skip to content
This repository has been archived by the owner on Aug 21, 2022. It is now read-only.

added custom fields to user model #69

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c5eec55
MYC-184 #comment Moved common into apps
milan-tom Feb 8, 2021
f3db20e
MYC-184 #comment Moved test_config.ini
milan-tom Feb 8, 2021
234e4ef
MYC-184 #comment Moved test_config.ini into apps/auth_zero/config/dat…
milan-tom Feb 8, 2021
be6289d
MYC-184 #comment Removed __init__.py file from config since it is not…
milan-tom Feb 8, 2021
d4ffef0
MYC-184 #comment Removed __init__.py file from common since it no lon…
milan-tom Feb 8, 2021
b460878
MYC-184 #comment Updated interfaces for loading files
milan-tom Feb 8, 2021
fedd851
MYC-184 #comment Merge changes from Feature/docker custom user model
milan-tom Feb 21, 2021
1a8ec38
MYC-184 #comment Fixed gitpod glitch
milan-tom Feb 21, 2021
801b72f
Merge remote-tracking branch 'upstream/master' into pr/custom-user-model
marcelloromani Feb 25, 2021
9362266
fix auth0 migrations
marcelloromani Feb 25, 2021
1bda33b
black formatter
marcelloromani Feb 25, 2021
aca92d2
fix codacy warning
marcelloromani Feb 25, 2021
46b5945
Merge branch 'master' into pr/custom-user-model
codecakes Mar 14, 2021
f4976e7
Merge branch 'develop' into pr/custom-user-model
codecakes Mar 27, 2021
cdc2dc0
Merge remote-tracking branch 'marcello/pr/custom-user-model' into pr/…
milan-tom Mar 27, 2021
d9296f4
Merge branch 'develop' into pr/custom-user-model
codecakes May 1, 2021
0445ebc
Merge branch 'develop' into pr/custom-user-model
codecakes May 2, 2021
2bc8353
Merge branch 'develop' into pr/custom-user-model
codecakes May 2, 2021
e38e029
Merge branch 'develop' into pr/custom-user-model
milan-tom May 3, 2021
9b24815
Changed name of test case class to better reflect purpose of test
milan-tom May 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed apps/auth_zero/config/__init__.py
Empty file.
18 changes: 14 additions & 4 deletions apps/auth_zero/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Generated by Django 3.0.7 on 2021-01-24 16:24
# Generated by Django 3.0.7 on 2021-02-25 16:20

from django.conf import settings
import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone
from django.conf import settings
from django.db import migrations
from django.db import models
import phonenumber_field.modelfields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -98,6 +99,15 @@ class Migration(migrations.Migration):
default=django.utils.timezone.now, verbose_name="date joined"
),
),
(
"mobile",
phonenumber_field.modelfields.PhoneNumberField(
blank=True, max_length=128, region=None
),
),
("last_otp", models.CharField(max_length=20, null=True)),
("otp_verified", models.BooleanField(default=False)),
("email_verified", models.BooleanField(default=False)),
(
"groups",
models.ManyToManyField(
Expand Down
31 changes: 0 additions & 31 deletions apps/auth_zero/migrations/0004_auto_20201227_1514.py

This file was deleted.

18 changes: 0 additions & 18 deletions apps/auth_zero/migrations/0005_user_email_verified.py

This file was deleted.

8 changes: 4 additions & 4 deletions apps/auth_zero/tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django.contrib.auth import get_user_model
from django.test import TestCase

from common.config import ConfigFileLoader
from common.config import CredentialsLoader
from apps.common.config import ConfigFileLoader
from apps.common.config import CredentialsLoader
milan-tom marked this conversation as resolved.
Show resolved Hide resolved


class UserTestCase(TestCase):
class UserVerificationTestCase(TestCase):
def setUp(self):
self.user_model = get_user_model()
config_file = "apps/auth_zero/config/test_config.ini"
config_file = "apps/auth_zero/config/data/test/test_config.ini"
self.creds_obj = CredentialsLoader(config_file, ConfigFileLoader)
self.users = {
verification_status: self.user_model.objects.create_user(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you create a user/interact outside of application logic boundary, it is no longer a "unit" test; this is an integration test;
You could try using interfaces that mock or rather override functionality so that actual DB operations are mimicked and some stubs take over; we assume that they do certain things and we can define those implementations;

Copy link
Collaborator

@milan-tom milan-tom Feb 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also write some unit tests creating and committing models with some edge cases for this model.
cases are when email is verified but mobile num is not and vice versa.
unless both of them are not verified user is not verified.
for that purpose, you could do something like:

class User:
  ..
  ..
  @property
  def is_verified(self):
    return self.otp_verified and self.email_verified

check again after running shell_plus or from DB model schema, i think its self.auth_user.email_verified ;

Could you give an example of how we could implement such interfaces in relation to the tests shown above, please?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still an issue?

Could you give an example of how we could implement such interfaces in relation to the tests shown above, please?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still an issue?

Could you give an example of how we could implement such interfaces in relation to the tests shown above, please?

Do I need to rewrite the tests, or are we proceeding with the currently written tests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to rewrite the tests, or are we proceeding with the currently written tests?

If the program is not accessing anything outside its own boundary; if you can run a Django test in flight mode with no SQL/NoSQL connected, then its a unit test;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I still work on this or will this not be applicable for the new repo?

Expand Down
File renamed without changes.
Empty file removed common/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions up-script.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
echo "=====migrate & runserver_plus====="
CPPFLAGS="$(pg_config --cppflags)" LDFLAGS="$(pg_config --ldflags)" bazel run :manage --watchfs --spawn_strategy=standalone --copt --aspects=@bazel_tools//tools/python:srcs_version.bzl%find_requirements --verbose_failures=true --show_timestamps=true --python_version=PY3 --build_python_zip --sandbox_debug --color=yes --curses=yes --jobs=2000 --loading_phase_threads=HOST_CPUS --action_env=LDFLAGS --action_env=CPPFLAGS --action_env=DEBUG_ENV --action_env=SECRET_KEY --action_env=BAZEL_CACHE --disk_cache=$BAZEL_CACHE -- collectstatic --noinput
CPPFLAGS="$(pg_config --cppflags)" LDFLAGS="$(pg_config --ldflags)" bazel run :manage --watchfs --spawn_strategy=standalone --copt --aspects=@bazel_tools//tools/python:srcs_version.bzl%find_requirements --verbose_failures=true --show_timestamps=true --python_version=PY3 --build_python_zip --sandbox_debug --color=yes --curses=yes --jobs=2000 --loading_phase_threads=HOST_CPUS --action_env=LDFLAGS --action_env=CPPFLAGS --action_env=DEBUG_ENV --action_env=SECRET_KEY --action_env=BAZEL_CACHE --disk_cache=$BAZEL_CACHE -- migrate;
CPPFLAGS="$(pg_config --cppflags)" LDFLAGS="$(pg_config --ldflags)" bazel run :manage --watchfs --spawn_strategy=standalone --copt --aspects=@bazel_tools//tools/python:srcs_version.bzl%find_requirements --verbose_failures=true --show_timestamps=true --python_version=PY3 --build_python_zip --sandbox_debug --color=yes --curses=yes --jobs=2000 --loading_phase_threads=HOST_CPUS --action_env=LDFLAGS --action_env=CPPFLAGS --action_env=DEBUG_ENV --action_env=SECRET_KEY --action_env=BAZEL_CACHE --disk_cache=$BAZEL_CACHE -- runserver_plus --cert-file ./certificate 0.0.0.0:8000;
CPPFLAGS="$(pg_config --cppflags)" LDFLAGS="$(pg_config --ldflags)" bazel run :manage --watchfs --spawn_strategy=standalone --copt --aspects=@bazel_tools//tools/python:srcs_version.bzl%find_requirements --verbose_failures=true --show_timestamps=true --python_version=PY3 --build_python_zip --sandbox_debug --color=yes --curses=yes --jobs=2000 --loading_phase_threads=HOST_CPUS --action_env=LDFLAGS --action_env=CPPFLAGS --action_env=DEBUG_ENV --action_env=SECRET_KEY --action_env=BAZEL_CACHE --disk_cache="$BAZEL_CACHE" -- collectstatic --noinput
CPPFLAGS="$(pg_config --cppflags)" LDFLAGS="$(pg_config --ldflags)" bazel run :manage --watchfs --spawn_strategy=standalone --copt --aspects=@bazel_tools//tools/python:srcs_version.bzl%find_requirements --verbose_failures=true --show_timestamps=true --python_version=PY3 --build_python_zip --sandbox_debug --color=yes --curses=yes --jobs=2000 --loading_phase_threads=HOST_CPUS --action_env=LDFLAGS --action_env=CPPFLAGS --action_env=DEBUG_ENV --action_env=SECRET_KEY --action_env=BAZEL_CACHE --disk_cache="$BAZEL_CACHE" -- migrate;
CPPFLAGS="$(pg_config --cppflags)" LDFLAGS="$(pg_config --ldflags)" bazel run :manage --watchfs --spawn_strategy=standalone --copt --aspects=@bazel_tools//tools/python:srcs_version.bzl%find_requirements --verbose_failures=true --show_timestamps=true --python_version=PY3 --build_python_zip --sandbox_debug --color=yes --curses=yes --jobs=2000 --loading_phase_threads=HOST_CPUS --action_env=LDFLAGS --action_env=CPPFLAGS --action_env=DEBUG_ENV --action_env=SECRET_KEY --action_env=BAZEL_CACHE --disk_cache="$BAZEL_CACHE" -- runserver_plus --cert-file ./certificate 0.0.0.0:8000;