Fakultas Ilmu Komputer UI

Commit fdfcf686 authored by igor lestin sianipar's avatar igor lestin sianipar Committed by I Gusti Putu Agastya Indrayana
Browse files

Pbi 2 login admin

parent fa101c82
from django.test import TestCase, Client
from django.urls import resolve
class TemplateLoaderTest(TestCase):
def test_template_loader_url_exist(self):
url = "/test-page.html"
response = Client().get(url)
self.assertEqual(response.status_code,200)
def test_template_loader_using_template_loader_template(self):
url = "/test-page.html"
response = Client().get(url)
expected_template_name = "test-page.html"
self.assertTemplateUsed(response, expected_template_name)
def test_template_loader_using_template_loader_func(self):
url = "/test-page.html"
found = resolve(url)
expected_view_name = "pages"
self.assertEqual(found.func.__name__, expected_view_name)
def test_template_loader_handle_non_existent_html(self):
url = "/test.html"
expected_template_name = "error-404.html"
response = Client().get(url)
self.assertEqual(response.status_code,200)
self.assertTemplateUsed(response, expected_template_name)
\ No newline at end of file
#class TemplateLoaderTest(TestCase):
# def test_template_loader_url_exist(self):
# url = "/test-page.html"
# response = Client().get(url)
# self.assertEqual(response.status_code,200)
#
# def test_template_loader_using_template_loader_template(self):
# url = "/test-page.html"
# response = Client().get(url)
# expected_template_name = "test-page.html"
# self.assertTemplateUsed(response, expected_template_name)
#
# def test_template_loader_using_template_loader_func(self):
# url = "/test-page.html"
# found = resolve(url)
# expected_view_name = "pages"
# self.assertEqual(found.func.__name__, expected_view_name)
#
# def test_template_loader_handle_non_existent_html(self):
# url = "/test.html"
# expected_template_name = "error-404.html"
# response = Client().get(url)
# self.assertEqual(response.status_code,200)
# self.assertTemplateUsed(response, expected_template_name)
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login Admin</title>
<!-- CSS -->
<link rel="stylesheet" href="../static/css/login_admin.css">
<link rel="stylesheet" type="text/css" href="../static/css/util.css">
<link rel="stylesheet" type="text/css" href="../static/css/main.css">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="../static/images/icons/logo.ico" />
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="../static/vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="../static/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
</head>
<body style="background-color: #f2f2f2;">
<br>
</br>
<br>
</br>
<div class="how_we_work_area">
<div class="container">
<div class="row">
<div class="col-lg-5">
<div class="login100-form-title p-b-43">
</div>
<div class="work_info">
<head>
<div class="login100-form-title p-b-43">
<img src="../static/images/logo.png" style="width:100px;height:100px;border:0;">
</div>
</head>
<div class="login100-form-title p-b-43">
Halo, Admin
</div>
<div class="wrap-input100 validate-input" data-validate="Valid email is required: ex@abc.xyz">
<input class="input100" type="text" name="email">
<span class="focus-input100"></span>
<span class="label-input100">Email</span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<input class="input100" type="password" name="pass">
<span class="focus-input100"></span>
<span class="label-input100">Password</span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn">
Login
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</br>
<!--===============================================================================================-->
<script src="../static/vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="../static/vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
<script src="../static/vendor/bootstrap/js/popper.js"></script>
<script src="../static/../static/../static/../static/../static/../static/vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="../static/../static/../static/../static/../static/vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="../static/../static/../static/../static/vendor/daterangepicker/moment.min.js"></script>
<script src="../static/../static/../static/vendor/daterangepicker/daterangepicker.js"></script>
<!--===============================================================================================-->
<script src="../static/../static/vendor/countdowntime/countdowntime.js"></script>
<!--===============================================================================================-->
<script src="../static/js/halaman_login.js"></script>
</body>
</html>
\ No newline at end of file
from django.test import TestCase, Client
from django.urls import resolve
from authentication.models import User
from .views import login_admin
class UserModelTest(TestCase):
def test_create_user(self):
......@@ -53,3 +53,43 @@ class UserModelTest(TestCase):
self.assertTrue(superuser.is_contributor)
self.assertTrue(superuser.is_staff)
self.assertTrue(superuser.is_superuser)
class Login_AdminPageTest(TestCase):
def test_register_url_is_exist(self):
# Positive tests
response = Client().get('/login_admin/')
self.assertEqual(response.status_code, 200)
# Negative tests
response = Client().get('/fake/')
self.assertEqual(response.status_code, 404)
def test_status_using_index_func(self):
# Positive tests
found = resolve('/login_admin/')
self.assertEqual(found.func, login_admin)
# Negative tests
found = resolve('/admin/')
self.assertNotEqual(found.func, login_admin)
def test_register_title(self):
response = Client().get('/login_admin/')
# Positive tests
self.assertContains(response, 'Login Admin')
# Negative tests
self.assertNotContains(response, 'Fake Title')
def test_register_form_field(self):
response = Client().get('/login_admin/')
# Positive tests
self.assertContains(response, 'Email')
self.assertContains(response, 'Password')
# Negative tests
self.assertNotContains(response, 'Jenis Kelamin')
from django.shortcuts import render
from django.http import HttpResponseRedirect
# Create your views here.
def login_admin(request):
return render(request, 'login_admin.html')
......@@ -153,4 +153,4 @@ STATIC_URL = '/static/'
STATIC_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
\ No newline at end of file
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
......@@ -14,9 +14,10 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include # add this
from django.urls import path
from authentication.views import login_admin
urlpatterns = [
path('admin/', admin.site.urls),
path("", include("app.urls")) # add this
path('login_admin/', login_admin, name='login_admin')
]
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