Fakultas Ilmu Komputer UI

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

adding coverage ci job and pipeline and coverage status on README.md

parent e3be4d4b
Pipeline #28506 failed with stages
in 55 minutes and 35 seconds
......@@ -74,3 +74,5 @@ FunctionalTest:
- python manage.py test tutorial_5.functional_tests
- python manage.py test tutorial_7.functional_tests
- python manage.py test -p "functional_test*.py"
- coverage run --include='tutorial_7/*' manage.py test
- coverage report -m
......@@ -2,6 +2,8 @@
#### **Izzan Fakhril Islam (1606875806)**
[![coverage report](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606875806-practice/badges/takehome-final-exam/coverage.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606875806-practice/commits/takehome-final-exam) [![pipeline status](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606875806-practice/badges/takehome-final-exam/pipeline.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606875806-practice/commits/takehome-final-exam)
**Daftar Tutorial:**
1. Tutorial 1: Web Page Pribadi berbasis *Python* dengan *Unit test*.
......
......@@ -29,3 +29,7 @@ class Tutorial1UnitTest(TestCase):
self.assertEqual(0, calculate_age(date.today().year))
self.assertEqual(19, calculate_age(2000))
self.assertEqual(29, calculate_age(1990))
def test_html_file_used(self):
response = Client().get('/tutorial-1/')
self.assertTemplateUsed(response, 'index_tutorial1.html')
from django.test import TestCase
# Create your tests here.
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)
def test_using_index_func(self):
found = resolve('/tutorial-7/')
self.assertEqual(found.func, index)
def test_author_name_availability(self):
author_name = "Izzan Fakhril Islam"
response = Client().get('/tutorial-7/')
html_response = response.content.decode('utf8')
self.assertIn(author_name, html_response)
def test_create_todo_redirect_response(self):
response = Client().post(
'/tutorial-7/add_todo/',
{
'date': '2019-12-12T05:44',
'activity': 'test'
}
)
self.assertEqual(response.status_code, 302)
def test_create_todo_commentary_redirect_response(self):
response = Client().post(
'/tutorial-7/add_todo_commentary/',
{
'date': '2019-12-12T05:44',
'activity': 'test commentary',
}
)
self.assertEqual(response.status_code, 302)
def test_delete_todo_redirect_response(self):
Client().post(
'/tutorial-7/add_todo/',
{
'date': '2019-12-12T05:44',
'activity': 'test'
}
)
delete_response = Client().get('/tutorial-7/1/delete_todo/')
self.assertEqual(delete_response.status_code, 302)
def test_delete_todo_commentary_redirect_response(self):
Client().post(
'/tutorial-7/add_todo_commentary/',
{
'date': '2019-12-12T05:44',
'activity': 'test commentary',
}
)
delete_response = Client().get('/tutorial-7/1/delete_todo_commentary/')
self.assertEqual(delete_response.status_code, 302)
def test_get_comment_by_count(self):
self.assertEqual(get_comment(5), "oh tidak")
self.assertEqual(get_comment(3), "sibuk tapi santai")
self.assertEqual(get_comment(0), "yey, waktunya berlibur")
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