diff --git a/README.md b/README.md index 39ca5f8454809f8cf870940412b01f3747763d6f..d279bf456ccf7ffa4778fa20281f8ad17181b290 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/coverage.svg b/coverage.svg index ae1c3500de8760b1a3e6ffbbd7d02403fab4b609..c1490035dbca46f993a9b7ffb6ca50ffa688312e 100644 --- a/coverage.svg +++ b/coverage.svg @@ -9,13 +9,13 @@ - + coverage coverage - 54% - 54% + 90% + 90% diff --git a/db.sqlite3 b/db.sqlite3 index 4fd81550fde7b53b36e850b1105ccbe6568c970d..04bb060b8d6de13d7ed64d1b85ecb634f5128a5f 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/lists/templates/base.html b/lists/templates/base.html index f126f08c2cffa437a4df2c960d666884b2a78c4a..51fdf5956e86ff969d0d055088b6ef4a22ffcf39 100644 --- a/lists/templates/base.html +++ b/lists/templates/base.html @@ -9,7 +9,7 @@ -
+
+ +
+ +
diff --git a/lists/tests.py b/lists/tests.py index ce8be8be7c158e5fd9782c87b3502b9134e951cf..25d472060bd0c2bbb16ae7d1d5cf3157fe9994fc 100644 --- a/lists/tests.py +++ b/lists/tests.py @@ -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() diff --git a/lists/urls.py b/lists/urls.py index 9d619c679f411325055a6e82c76180f166edf7ea..297f59e49dbf18a6b20cb1f80c66139dce2d0c64 100644 --- a/lists/urls.py +++ b/lists/urls.py @@ -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 diff --git a/lists/views.py b/lists/views.py index 9457be23a8712ac4ef6611a032e61529d182fab6..235df8b22d8a380ee1dbf020f6378cdd85e2ddd9 100644 --- a/lists/views.py +++ b/lists/views.py @@ -1,6 +1,6 @@ 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 diff --git a/superlists/urls.py b/superlists/urls.py index 4e14dcb47eaf65eb67eef775a9f04a31cf06e5c8..208f663f0cd50d9429471292d997d6b149316c99 100644 --- a/superlists/urls.py +++ b/superlists/urls.py @@ -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)), ]