Fakultas Ilmu Komputer UI

Commit e11179c2 authored by Izzatul Muttaqin's avatar Izzatul Muttaqin
Browse files

Create new project to resolve error

parent e05b4ead
# Created by https://www.gitignore.io/api/python,intellij+iml
### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# dotenv
.env
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# End of https://www.gitignore.io/api/python,intellij+iml
#Ignore files for Lab1
db.sqlite3
chromedriver
chromedriver.exe
geckodriver.log
__pycache__/
*/migrations/
\ No newline at end of file
stages:
- test
- deploy
- functional_test
UnitTest:
image: python:3.6
stage: test
before_script:
- pip3 install -r requirements.txt
- pip3 install requests
- pip3 install django-environ
- python3 manage.py makemigrations
- python3 manage.py migrate
- python3 manage.py collectstatic --no-input
- python3 manage.py runserver 8000 &
when: on_success
script:
- coverage run --include='personal_*' manage.py test
- coverage report -m
Deployment:
image: ruby:2.4
stage: deploy
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
script:
- dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY
- export HEROKU_API_KEY=$HEROKU_APIKEY
- heroku ps:scale web=1 migrate=1 --app $HEROKU_APPNAME
- heroku ps:restart --app=$HEROKU_APPNAME
environment:
name: production
url: $HEROKU_APP_HOST
only:
- master
FunctionalTest:
image: python:3.6
stage: functional_test
before_script:
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
- pip3 install -r requirements.txt
- pip3 install requests
- pip3 install django-environ
- apt-get update -qq && apt-get install -y -qq unzip
- apt-get install -y google-chrome-stable
- apt-get install -y xvfb
- wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
when: on_success
script:
- python3 functional_tests.py
only:
- master
\ No newline at end of file
migrate: bash deployment.sh
web: gunicorn testproject.wsgi --log-file -
\ No newline at end of file
# 1606837915-practice
[Izzatul Muttaqin - PMPL A](https://pmpl-project.herokuapp.com/)
\ No newline at end of file
#!/bin/bash
python manage.py makemigrations
python manage.py migrate
\ No newline at end of file
from selenium import webdriver
from django.test import LiveServerTestCase
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.chrome.options import Options
import unittest
class NewVisitorTest(unittest.TestCase):
def setUp(self):
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('disable-gpu')
try:
self.browser = webdriver.Chrome('./chromedriver.exe', chrome_options=chrome_options)
except:
self.browser = webdriver.Chrome('./chromedriver', chrome_options=chrome_options)
super(NewVisitorTest, self).setUp()
def tearDown(self):
self.browser.close()
def check_for_row(self, row_text):
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])
def test_can_start_a_list_and_retrieve_it_later(self):
self.browser.get('https://pmpl-project.herokuapp.com/lists')
self.assertIn('To-Do', self.browser.title)
header_text = self.browser.find_element_by_tag_name('h1').text
self.assertIn('To-Do', header_text)
inputbox = self.browser.find_element_by_id('id_new_item')
self.assertEqual(
inputbox.get_attribute('placeholder'),
'Enter a to-do item'
)
inputbox.send_keys('Buy peacock feathers')
inputbox.send_keys(Keys.ENTER)
WebDriverWait(self.browser, 10).until(
expected_conditions.text_to_be_present_in_element(
(By.ID, 'id_list_table'), 'Buy peacock feathers'))
self.check_for_row('1: Buy peacock feathers')
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Use peacock feathers to make a fly')
inputbox.send_keys(Keys.ENTER)
table = self.browser.find_element_by_id('id_list_table')
rows = table.find_elements_by_tag_name('tr')
self.check_for_row('1: Buy peacock feathers')
WebDriverWait(self.browser, 10).until(
expected_conditions.text_to_be_present_in_element(
(By.ID, 'id_list_table'), 'Use peacock feathers to make a fly'))
self.check_for_row('2: Use peacock feathers to make a fly')
# self.fail('Finish the test!')
if __name__ == '__main__':
unittest.main(warnings='ignore')
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
# Created by https://www.gitignore.io/api/python,intellij+iml
### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# dotenv
.env
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# End of https://www.gitignore.io/api/python,intellij+iml
#Ignore files for Lab1
db.sqlite3
chromedriver
chromedriver.exe
geckodriver.log
__pycache__/
\ No newline at end of file
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class PersonalPageConfig(AppConfig):
name = 'personal_page'
from django.db import models
# Create your models here.
<html>
<title>Home Page {{ name }}</title>
<body>
<h1>Hello, this is {{ name }}.</h1>
</body>
</html>
\ No newline at end of file
from django.test import TestCase
from django.test import Client
from django.urls import resolve
from .views import home_page
from django.http import HttpRequest
from unittest import skip
# Create your tests here.
class PersonalPage(TestCase):
def test_url_is_exist(self):
response = Client().get('/')
self.assertEqual(response.status_code,200)
def test_using_home_page_func(self):
found = resolve('/')
self.assertEqual(found.func, home_page)
def test_landing_page_is_completed(self):
request = HttpRequest()
response = home_page(request)
html_response = response.content.decode('utf8')
self.assertIn('Hello, this is Izzatul Muttaqin.', html_response)
from django.conf.urls import url
from .views import home_page
#url for app
urlpatterns = [
url(r'^$', home_page, name='home_page')
]
\ No newline at end of file
from django.shortcuts import render
def home_page(request):
return render(request, 'screen/home.html',{'name': 'Izzatul Muttaqin'})
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class PersonalTodoConfig(AppConfig):
name = 'personal_todo'
def counter_comment(number):
if number == 0:
return 'yey, waktunya libur'
if (number < 5 and number > 0):
return 'sibuk tapi santai'
if number >= 5:
return 'oh tidak'
return 'input tidak valid'
\ No newline at end of file
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