Fakultas Ilmu Komputer UI

Commit bb8f720b authored by Aviliani Pramestya's avatar Aviliani Pramestya
Browse files

Uas 1

parent b1b9b109
......@@ -6,3 +6,8 @@ __pycache__
*.pyc
chromedriver.exe
/static
.coverage
.coverage.*
coverage.xml
accounts/tests/__pycache__/*
lists/tests/__pycache__/*
......@@ -14,6 +14,8 @@ lists:
- python3 manage.py migrate
- python3 manage.py collectstatic --no-input
script:
- coverage run --source=lists manage.py test lists
- coverage report -m
- python3 manage.py test lists
accounts:
......@@ -28,6 +30,8 @@ accounts:
- python3 manage.py migrate
- python3 manage.py collectstatic --no-input
script:
- coverage run --source=accounts manage.py test accounts
- coverage report -m
- python3 manage.py test accounts
functional_test:
......@@ -45,4 +49,6 @@ functional_test:
- python3 manage.py makemigrations
- python3 manage.py migrate
script:
- coverage run --source=functional_tests manage.py test functional_tests
- coverage report -m
- python3 manage.py test functional_tests
......@@ -36,48 +36,16 @@ class FunctionalTest(StaticLiveServerTestCase):
def wait_for(self, fn):
return fn()
# def wait_for_row_in_list_table(self, row_text):
# start_time = time.time()
# while True:
# try:
# table = self.browser.find_element_by_id('id_list_table')
# rows = table.find_elements_by_tag_name('tr')
# self.assertIn(row_text, [row.text for row in rows])
# return
# except (AssertionError, WebDriverException) as e:
# if time.time() - start_time > MAX_WAIT:
# raise e
# time.sleep(0.5)
# def wait_for(self, fn):
# start_time = time.time()
# while True:
# try:
# return fn()
# except (AssertionError, WebDriverException) as e:
# if time.time() - start_time > MAX_WAIT:
# raise e
# time.sleep(0.5)
# def wait_to_be_logged_in(self, email):
# self.wait_for(
# lambda: self.browser.find_element_by_link_text('Log out')
# )
# navbar = self.browser.find_element_by_css_selector('.navbar')
# self.assertIn(email, navbar.text)
# def wait_to_be_logged_out(self, email):
# self.wait_for(
# lambda: self.browser.find_element_by_name('email')
# )
# navbar = self.browser.find_element_by_css_selector('.navbar')
# self.assertNotIn(email, navbar.text)
@wait
def wait_for_row_in_list_table(self, row_text):
table = self.browser.find_element_by_id('id_list_table')
rows = table.find_elements_by_tag_name('tr')
rows = table.find_elements_by_tag_name('td')
self.assertIn(row_text, [row.text for row in rows])
@wait
def wait_for_title_in_list_table(self, row_text):
table = self.browser.find_element_by_id('id_list_table')
rows = table.find_elements_by_tag_name('th')
self.assertIn(row_text, [row.text for row in rows])
@wait
......
......@@ -5,6 +5,14 @@ from .base import FunctionalTest
class LayoutAndStylingTest(FunctionalTest):
def test_name_in_header_and_footer(self):
self.browser.get(self.live_server_url)
header = self.browser.find_element_by_id('name_header').text
footer = self.browser.find_element_by_id('name_footer').text
self.assertIn('Aviliani Pramestya', header)
self.assertIn('Aviliani Pramestya', footer)
def test_layout_and_styling(self):
# Edith goes to the home page
self.browser.get(self.live_server_url)
......@@ -32,13 +40,13 @@ class LayoutAndStylingTest(FunctionalTest):
rows = h1_elem.find_elements_by_tag_name('h1')
self.assertIn("sibuk tapi santai", [row.text for row in rows])
def test_body_contains_name_in_h1(self):
self.browser.get(self.live_server_url)
h1_elem = self.browser.find_element_by_tag_name('h1')
self.assertIn('Aviliani Pramestya', h1_elem.text)
# def test_body_contains_name_in_h1(self):
# self.browser.get(self.live_server_url)
# h1_elem = self.browser.find_element_by_tag_name('h1')
# self.assertIn('Aviliani Pramestya', h1_elem.text)
def test_body_contains_npm_in_h1(self):
self.browser.get(self.live_server_url)
h1_elem = self.browser.find_element_by_tag_name('h2')
self.assertIn('1606829402', h1_elem.text)
# def test_body_contains_npm_in_h1(self):
# self.browser.get(self.live_server_url)
# h1_elem = self.browser.find_element_by_tag_name('h2')
# self.assertIn('1606829402', h1_elem.text)
......@@ -21,6 +21,8 @@ class ItemValidationTest(FunctionalTest):
# She tries again with some text for the item, which now works
self.browser.find_element_by_id('id_new_item').send_keys('Buy milk')
self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER)
self.wait_for_title_in_list_table("To Do List")
self.wait_for_title_in_list_table("Created at")
self.wait_for_row_in_list_table('1: Buy milk')
# Perversely, she now decides to submit a second blank list item
......@@ -35,5 +37,7 @@ class ItemValidationTest(FunctionalTest):
# And she can correct it by filling some text in
self.browser.find_element_by_id('id_new_item').send_keys('Make tea')
self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER)
self.wait_for_title_in_list_table("To Do List")
self.wait_for_title_in_list_table("Created at")
self.wait_for_row_in_list_table('1: Buy milk')
self.wait_for_row_in_list_table('2: Make tea')
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-12-22 16:04
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lists', '0002_auto_20191009_1640'),
]
operations = [
migrations.AddField(
model_name='item',
name='date',
field=models.TextField(default='22 12 2019 23:04:06'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-12-22 16:45
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lists', '0003_item_date'),
]
operations = [
migrations.AlterField(
model_name='item',
name='date',
field=models.TextField(default='22-12-2019 23:45:18'),
),
]
from django.db import models
from datetime import datetime
# Create your models here.
class List(models.Model):
......@@ -7,3 +8,4 @@ class List(models.Model):
class Item(models.Model):
text = models.TextField(default='')
list = models.ForeignKey(List, default=None, on_delete=models.CASCADE)
date = models.TextField(default=datetime.now().strftime("%d-%m-%Y %H:%M:%S"))
#id_new_item {
margin-top: 2ex;
}
#name_header {
font-size: 18px;
font-weight: bold;
text-align: center;
margin-bottom: 20px;
}
#name_footer {
margin-bottom: 5px;
text-align: center;
font-size: 15px;
font-weight: bold;
}
.navbar-brand {
font-size: 18px;
font-weight: bold;
}
\ No newline at end of file
......@@ -40,6 +40,7 @@
{% csrf_token %}
</form>
{% endif %}
<p id="name_header">Aviliani Pramestya</p>
</div>
</nav>
......@@ -59,7 +60,7 @@
<div class="row">
<!-- <div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="text-center">
<h1>Aviliani Pramestya</h1>
......@@ -68,7 +69,7 @@
​ </div>
</div>
<hr/>
<hr/> -->
<div class="row">
<div class="col-md-6 col-md-offset-3 jumbotron">
......@@ -102,5 +103,9 @@
</div>
</div>
<div class="footer">
<p id="name_footer">Aviliani Pramestya © 2019</p>
</div>
</body>
</html>
......@@ -6,8 +6,15 @@
{% block table %}
<table id="id_list_table" class="table">
<tr>
<th>To Do List</th>
<th>Created at</th>
<tr>
​{% for item in list.item_set.all %}
<tr><td>{{ forloop.counter }}: {{ item.text }}</td></tr>
<tr>
<td>{{ forloop.counter }}: {{ item.text }}</td>
<td>{{ item.date }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
......
......@@ -135,7 +135,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/Jakarta'
USE_I18N = True
......
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