Fakultas Ilmu Komputer UI

Commit 1aaa0c4c authored by Izzan Fakhril Islam's avatar Izzan Fakhril Islam
Browse files

Merge branch 'master' into 'tutorial-1'

# Conflicts:
#   .gitignore
#   .gitlab-ci.yml
#   tutorial_1/tests.py
parent 68486611
......@@ -501,5 +501,6 @@ typings/
# Ignore all local history of files
.history
.env
chromedriver
# End of https://www.gitignore.io/api/node,macos,python,django,intellij,intellij+all,intellij+iml,visualstudiocode
......@@ -10,14 +10,19 @@ UnitTest:
- apt-get install -y python-dev python-pip sudo postgresql postgresql-client libpq-dev libxss1 libappindicator1 libindicator7
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
- apt-get update
- apt-get update -qq && apt-get install -y -qq unzip
- apt-get install -y google-chrome-stable
- export CHROME_BIN=/usr/bin/google-chrome
- google-chrome --version
- apt-get install -y xvfb
- wget https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- service postgresql start
- sudo -u $DB_DEFAULT_OWNER psql -c "CREATE USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD' CREATEDB"
- sudo -u $DB_DEFAULT_OWNER psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USERNAME"
- pip install --upgrade pip
- pip install -r requirements.txt
- pip install --upgrade --ignore-installed urllib3
- python manage.py makemigrations
- python manage.py migrate
- python manage.py collectstatic --no-input
......
## Repository Tutorial PMPL
------
#### **Izzan Fakhril Islam (1606875806)**
**Daftar Tutorial:**
1. Tutorial 1: Web Page Pribadi berbasis *Python* dengan *Unit test*.
**URL Heroku:** https://pmpl-izzan.herokuapp.com
\ No newline at end of file
**URL Heroku:** https://pmpl-izzan.herokuapp.com
from django.test import TestCase
from django.test import Client
from django.urls import resolve
from .views import index, NAME, calculate_age
from django.http import HttpRequest
from datetime import date
import unittest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
# Create your tests here.
......@@ -31,3 +31,29 @@ class Tutorial1UnitTest(TestCase):
self.assertEqual(0, calculate_age(date.today().year))
self.assertEqual(19, calculate_age(2000))
self.assertEqual(29, calculate_age(1990))
class Tutorial1FunctionalTest(TestCase):
def setUp(self):
chrome_options = Options()
chrome_options.add_argument('--dns-prefatch-disable')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
self.selenium = webdriver.Chrome('./chromedriver', chrome_options=chrome_options)
super(Tutorial1FunctionalTest, self).setUp()
def tearDown(self):
self.selenium.quit()
super(Tutorial1FunctionalTest, self).tearDown()
def test_find_name(self):
selenium = self.selenium
selenium.get('http://127.0.0.1:8000/tutorial-1/')
self.assertIn(NAME, selenium.page_source)
def test_find_age(self):
selenium = self.selenium
selenium.get('http://127.0.0.1:8000/tutorial-1/')
self.assertIn('21', selenium.page_source)
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