Fakultas Ilmu Komputer UI

Commit aa175c92 authored by Izzan Fakhril Islam's avatar Izzan Fakhril Islam
Browse files

fixing email functional test

parent af4c5929
Pipeline #28556 failed with stages
in 13 minutes and 38 seconds
......@@ -111,7 +111,6 @@ elif GITLAB_ENV:
}
}
}
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD")
else:
DATABASES = {
'default': {
......@@ -126,7 +125,6 @@ else:
}
}
}
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
......@@ -149,6 +147,7 @@ AUTH_PASSWORD_VALIDATORS = [
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'rvd.cena@gmail.com'
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
EMAIL_PORT = 587
EMAIL_USE_TLS = True
......
from django.core import mail
from selenium.webdriver.common.keys import Keys
import re
from unittest import skip
from .base import FunctionalTest
......
......@@ -2,14 +2,13 @@ from django.http import HttpRequest
from django.test import TestCase
from django.test import Client
from django.urls import resolve
from django.contrib.auth import get_user_model
from tutorial_7.views import *
class Tutorial7AppUnitTest(TestCase):
def test_url_is_exist(self):
response = Client().get('/tutorial-7/')
self.assertEqual(response.status_code, 200)
response_main_page = Client().get('/tutorial-7/')
self.assertEqual(response_main_page.status_code, 200)
def test_using_index_func(self):
found = resolve('/tutorial-7/')
......@@ -17,29 +16,49 @@ class Tutorial7AppUnitTest(TestCase):
def test_author_name_availability(self):
author_name = "Izzan Fakhril Islam"
response = Client().get('/tutorial-7/')
html_response = response.content.decode('utf8')
response_author = Client().get('/tutorial-7/')
html_response = response_author.content.decode('utf8')
self.assertIn(author_name, html_response)
def test_create_todo_redirect_response(self):
response = Client().post(
response_create_todo = Client().post(
'/tutorial-7/add_todo/',
{
'date': '2019-12-12T05:44',
'activity': 'test'
}
)
self.assertEqual(response.status_code, 302)
self.assertEqual(response_create_todo.status_code, 302)
def test_create_todo_failed_rendered_response(self):
response_create_todo = Client().post(
'/tutorial-7/add_todo/',
{
'date': '2019-121231',
'activity': 'test'
}
)
self.assertEqual(response_create_todo.status_code, 200)
def test_create_todo_commentary_redirect_response(self):
response = Client().post(
response_create_todo_commentary = Client().post(
'/tutorial-7/add_todo_commentary/',
{
'date': '2019-12-12T05:44',
'activity': 'test commentary',
'date': '2019-12-12',
'comment': 'test commentary',
}
)
self.assertEqual(response_create_todo_commentary.status_code, 302)
def test_create_todo_commentary_failed_rendered_response(self):
response_create_todo_commentary = Client().post(
'/tutorial-7/add_todo_commentary/',
{
'date': '2019-12-121231-123',
'comment': 'test commentary',
}
)
self.assertEqual(response.status_code, 302)
self.assertEqual(response_create_todo_commentary.status_code, 200)
def test_delete_todo_redirect_response(self):
Client().post(
......
from django.test import TestCase
from django.contrib.auth import get_user_model
from tutorial_7.models import Token
from datetime import datetime
from tutorial_7.models import Token, TodoList, TodoListCommentary
User = get_user_model()
......@@ -22,3 +23,20 @@ class TokenModelTest(TestCase):
token1 = Token.objects.create(email='a@b.com')
token2 = Token.objects.create(email='a@b.com')
self.assertNotEqual(token1.uid, token2.uid)
class TodoListAndCommentaryModelTest(TestCase):
def test_todo_list_model_is_created(self):
TodoList.objects.create(
todo_list='Hello!',
date=datetime.strptime('2019-12-12T15:15', '%Y-%m-%dT%H:%M')
)
self.assertEqual(TodoList.objects.count(), 51)
def test_todo_list_commentary_model_is_created(self):
TodoListCommentary.objects.create(
comment='Comment',
date=datetime.strptime('2019-12-12', '%Y-%m-%d')
)
self.assertEqual(TodoListCommentary.objects.count(), 51)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment