Fakultas Ilmu Komputer UI

Commit 05f0ec81 authored by MADE WIRA DHANAR SANTIKA's avatar MADE WIRA DHANAR SANTIKA
Browse files

New of Feature/Todo

parent c03e6cbc
......@@ -6,4 +6,6 @@ __pycache__
env/
.env
chromedriver
migrations/
\ No newline at end of file
migrations/
static/
.coverage
\ No newline at end of file
......@@ -9,10 +9,12 @@ unit-test:
before_script:
- pip install -r requirements.txt
- cd homepage
- python manage.py collectstatic --no-input
- python manage.py makemigrations
- python manage.py migrate
script:
- python manage.py test
- coverage run --source=./ manage.py test
- coverage report -m
deploy:
image: ruby
......@@ -20,6 +22,7 @@ deploy:
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
- cd homepage
script:
- dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY
- export HEROKU_API_KEY=$HEROKU_APIKEY
......
migrate: bash deployment.sh
web: cd homepage && gunicorn homepage.wsgi --log-file -
\ No newline at end of file
web: gunicorn homepage.wsgi --log-file -
\ No newline at end of file
### Made Wira Dhanar Santika - 1606880996 - Computer Science 2016 - PMPL A - Practice Repo
[![pipeline status](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606880996-practice/badges/master/pipeline.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606880996-practice/commits/master)
[![coverage report](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606880996-practice/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606880996-practice/commits/master)
url : http://pmpl-dhanar.herokuapp.com/
\ No newline at end of file
#!/bin/bash
cd homepage
python manage.py makemigrations
python manage.py migrate
\ No newline at end of file
......@@ -50,6 +50,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'homepage.urls'
......@@ -88,8 +89,6 @@ DATABASES = {
if PRODUCTION:
DATABASES['default'] = dj_database_url.config()
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
......@@ -123,7 +122,9 @@ USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATIC_URL = '/static/'
\ No newline at end of file
{% load staticfiles %}
{% load static %}
<html>
<head>
<title>To-Do Lists</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/todo.css' %}">
</head>
<body>
<h1>Your To-Do Lists</h1>
<p>{{ comment }}</p>
<form method="POST">
<input name="item_text" id="id_new_item" placeholder="Enter a to-do item" />
{% csrf_token %}
</form>
<table id="id_list_table">
{% for item in items %}
<tr><td>{{forloop.counter}}: {{ item.text }}</td></tr>
{% endfor %}
</table>
<div class="todo">
<h1>Your To-Do Lists</h1>
<p class="comment">{{ comment }}</p>
<form method="POST">
<input name="item_text" id="id_new_item" placeholder="Enter a to-do item" />
{% csrf_token %}
</form>
<table id="id_list_table">
{% for item in items %}
<tr><td>{{forloop.counter}}: {{ item.text }}</td></tr>
{% endfor %}
</table>
</div>
</body>
</html>
\ No newline at end of file
......@@ -14,27 +14,10 @@ class TodoPageTests(TestCase):
def test_todo_return_correct_html(self):
request = HttpRequest()
response = todo(request)
self.assertTrue(response.content.startswith(b'<html>'))
self.assertTrue(response.content.startswith(b'\n\n\n<html>\n'))
self.assertIn(b'<title>To-Do Lists</title>', response.content)
self.assertTrue(response.content.endswith(b'</html>'))
def test_todo_page_can_save_a_POST_request(self):
request = HttpRequest()
request.method = "POST"
request.POST["item_text"] = "A new list item"
response = todo(request)
self.assertIn("A new list item", response.content.decode())
expected_html = render_to_string(
'todo.html',
{'new_item_text': 'A new list item'}
)
# Change assertEqual to assertIn due to csrf_token
# being ignored by render_to_string
self.assertIn("A new list item", response.content.decode())
self.assertIn("A new list item", expected_html)
def test_todo_page_can_save_a_POST_request(self):
request = HttpRequest()
request.method = 'POST'
......@@ -73,7 +56,7 @@ class TodoPageTests(TestCase):
response = todo(request)
self.assertEqual(0, Item.objects.count())
self.assertIn("<p>yey, waktunya berlibur</p>", response.content.decode())
self.assertIn("<p class=\"comment\">yey, waktunya berlibur</p>", response.content.decode())
def test_todo_page_get_custom_comment_if_items_is_1(self):
Item.objects.create(text='dead 1')
......@@ -81,7 +64,7 @@ class TodoPageTests(TestCase):
response = todo(request)
self.assertEqual(1, Item.objects.count())
self.assertIn("<p>sibuk tapi santai</p>", response.content.decode())
self.assertIn("<p class=\"comment\">sibuk tapi santai</p>", response.content.decode())
def test_todo_page_get_custom_comment_if_items_is_too_many(self):
for i in range(100):
......@@ -91,7 +74,7 @@ class TodoPageTests(TestCase):
response = todo(request)
self.assertEqual(100, Item.objects.count())
self.assertIn("<p>oh tidak</p>", response.content.decode())
self.assertIn("<p class=\"comment\">oh tidak</p>", response.content.decode())
class ItemModelTest(TestCase):
def test_saving_and_retrieving_items(self):
......
astroid==2.2.5
coverage==4.5.4
dj-database-url==0.5.0
Django==2.2.5
gunicorn==19.9.0
......@@ -14,4 +15,5 @@ six==1.12.0
sqlparse==0.3.0
typed-ast==1.4.0
urllib3==1.25.3
whitenoise==4.1.4
wrapt==1.11.2
Markdown is supported
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