Fakultas Ilmu Komputer UI

Commit 04c3ac98 authored by Dwi Nanda Susanto's avatar Dwi Nanda Susanto
Browse files

[IMPLEMENTATION] create function for reset all items at a certain...

[IMPLEMENTATION] create function for reset all items at a certain lists/{list.id}/ and go back to / after reset items on that list.id page
parent 3ea50fba
......@@ -5,9 +5,86 @@
The **deployed** simple home page can be accessed here :
[http://dwi-simplehomepage.herokuapp.com/](http://dwi-simplehomepage.herokuapp.com/)
[![pipeline status](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/badges/fix_uas_take_home/pipeline.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/commits/fix_uas_take_home)
[![pipeline status](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/badges/fix_uas_take_home/pipeline.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/commits/master)
[![coverage report](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/badges/fix_uas_take_home/coverage.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/commits/fix_uas_take_home)
[![coverage report](coverage.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1506722720-practice/commits/master)
# UAS TAKE HOME PROGRAMMING
`duration of coding : almost 4 days`
first task is done : implementing header and footer in SQA way, branch is `fix_uas_take_home`
second task is done also : create my own feature, `reset all items` on branch `new_ftr_uas_take_home`
>here below is the code coverage for the the `unittest`
```
$ coverage report
Name Stmts Miss Cover
-----------------------------------------------------------
accounts/__init__.py 0 0 100%
accounts/admin.py 1 0 100%
accounts/authentication.py 22 0 100%
accounts/migrations/0001_initial.py 6 0 100%
accounts/migrations/__init__.py 0 0 100%
accounts/models.py 30 4 87%
accounts/tests/test_authentication.py 30 0 100%
accounts/tests/test_models.py 13 0 100%
accounts/tests/test_views.py 29 0 100%
accounts/urls.py 4 0 100%
accounts/views.py 28 2 93%
lists/__init__.py 0 0 100%
lists/admin.py 1 0 100%
lists/migrations/0001_initial.py 6 0 100%
lists/migrations/__init__.py 0 0 100%
lists/models.py 6 0 100%
lists/tests.py 74 0 100%
lists/urls.py 3 0 100%
lists/views.py 30 21 30%
manage.py 13 6 54%
superlists/__init__.py 0 0 100%
superlists/settings.py 30 0 100%
superlists/urls.py 7 0 100%
-----------------------------------------------------------
TOTAL 333 33 90%
Job succeeded
```
>and here below is the code coverage for the `functional test`
```
$ coverage report -m
Name Stmts Miss Cover Missing
----------------------------------------------------------------------------
accounts/__init__.py 0 0 100%
accounts/admin.py 1 0 100%
accounts/apps.py 3 3 0% 1-5
accounts/authentication.py 22 6 73% 10-11, 16-17, 25-26
accounts/migrations/0001_initial.py 6 0 100%
accounts/migrations/__init__.py 0 0 100%
accounts/models.py 30 4 87% 20, 22, 33, 37
accounts/tests.py 1 0 100%
accounts/urls.py 4 0 100%
accounts/views.py 28 0 100%
functional_test/__init__.py 0 0 100%
functional_test/base.py 55 18 67% 34-37, 41-56, 76-77
functional_test/test_layout_and_styling.py 9 0 100%
functional_test/test_list_item_validation.py 15 8 47% 12-19
functional_test/test_login.py 36 4 89% 38, 76-78
functional_test/test_my_lists.py 32 4 88% 44-47
functional_test/tests.py 52 12 77% 43-58
lists/__init__.py 0 0 100%
lists/admin.py 1 0 100%
lists/apps.py 3 3 0% 1-5
lists/migrations/0001_initial.py 6 0 100%
lists/migrations/__init__.py 0 0 100%
lists/models.py 6 0 100%
lists/tests.py 74 0 100%
lists/urls.py 3 0 100%
lists/views.py 30 11 63% 15, 19, 29-31, 34-40
----------------------------------------------------------------------------
TOTAL 417 73 82%
Job succeeded
```
# Exercise 3
Pada exercise 3 kali ini dibuat sebuah integration test yang akan mengautomasi waktu menunggu hingga terjadi perubahan pada rows.
......
......@@ -9,13 +9,13 @@
</mask>
<g mask="url(#a)">
<path fill="#555" d="M0 0h63v20H0z"/>
<path fill="#fe7d37" d="M63 0h36v20H63z"/>
<path fill="#97CA00" d="M63 0h36v20H63z"/>
<path fill="url(#b)" d="M0 0h99v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
<text x="31.5" y="14">coverage</text>
<text x="80" y="15" fill="#010101" fill-opacity=".3">54%</text>
<text x="80" y="14">54%</text>
<text x="80" y="15" fill="#010101" fill-opacity=".3">90%</text>
<text x="80" y="14">90%</text>
</g>
</svg>
No preview for this file type
......@@ -9,7 +9,7 @@
</head>
<body>
<div class="header">
<div class="header" style="text-align:center;">
<p id="header">Dwi Nanda S</p>
</div>
<nav class="navbar navbar-default" role="navigation">
......@@ -44,9 +44,13 @@
{% block table %} {% endblock %}
</div>
</div>
</div>
<form action="reset_items/" method="GET" style="text-align:center;">
<button type='submit'>RESET ITEM</button>
</form>
<div class="footer">
<p id="footer">Dwi Nanda S</p>
<p id="footer" style="text-align:center;">Dwi Nanda S</p>
</div>
</body>
......
......@@ -65,6 +65,20 @@ class HomePageTest(TestCase):
response = self.client.get('/')
self.assertIn('oh tidak', 'oh tidak')
def test_delete_all_items(self):
for i in range(6):
Item.objects.create(text='itemey %d' % i)
all_items = Item.objects.all()
if len(all_items) > 0 :
for i in all_items:
i.delete()
else:
pass
response = self.client.get('/')
self.assertNotIn('itemey 1', response.content.decode('utf8'))
class ItemModelTest(TestCase):
def test_saving_and_retrieving_items(self):
first_item = Item()
......
......@@ -2,7 +2,8 @@ from django.conf.urls import url
from lists import views
urlpatterns = [
url(r'^new$', views.new_list, name='new_list'),
url(r'^(\d+)/$', views.view_list, name='view_list'),
url(r'^(\d+)/add_item$', views.add_item, name='add_item'),
]
url(r'^new$', views.new_list, name='new_list'),
url(r'^(\d+)/$', views.view_list, name='view_list'),
url(r'^(\d+)/add_item$', views.add_item, name='add_item'),
url(r'^(\d+)/reset_items/$', views.reset_items, name='reset_items'),
]
\ No newline at end of file
from django.shortcuts import redirect, render
from lists.models import Item
from lists.models import Item, List
from django.http import HttpResponse
def home_page(request):
return render(request, 'home.html')
......@@ -29,3 +29,13 @@ def add_item(request, list_id):
list_ = List.objects.get(id=list_id)
Item.objects.create(text=request.POST['item_text'], list=list_)
return redirect(f'/lists/{list_.id}/')
def reset_items(request, list_id):
print("AAAAAAAAAAAAAAAAA----")
if request.method == 'GET':
Item.objects.all().delete()
return redirect('/')
items = Item.objects.all()
return redirect('/')
\ No newline at end of file
......@@ -2,9 +2,11 @@ from django.conf.urls import include, url
from lists import views as list_views
from lists import urls as list_urls
from accounts import urls as accounts_urls
from django.urls import path
from lists import views
urlpatterns = [
url(r'^$', list_views.home_page, name='home'),
url(r'^lists/', include(list_urls)),
url(r'^accounts/', include(accounts_urls)),
url(r'^$', list_views.home_page, name='home'),
url(r'^lists/', include(list_urls)),
url(r'^accounts/', include(accounts_urls)),
]
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