diff --git a/.coverage b/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..f9507ef175fcb3169f97564c75651382430328a2 --- /dev/null +++ b/.coverage @@ -0,0 +1 @@ +!coverage.py: This is a private format, don't read it directly!{"lines":{"E:\\Tugas\\PMPL\\testinggoatch1-3\\superlists\\__init__.py":[1],"E:\\Tugas\\PMPL\\testinggoatch1-3\\superlists\\settings.py":[11,13,16,23,26,28,34,35,36,37,38,39,40,44,45,46,47,48,49,50,53,57,58,59,61,62,63,64,65,71,78,79,80,90,93,96,99,107,109,111,113,115,121],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\__init__.py":[1],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\models.py":[1],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\admin.py":[1],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\migrations\\__init__.py":[1],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\tests.py":[1,2,3,4,5,7,8,12,16,13,14,17,18,19,20,21,22,9,10],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\views.py":[1,2,5,6,7,8,9],"E:\\Tugas\\PMPL\\testinggoatch1-3\\superlists\\urls.py":[1,2,3,7],"E:\\Tugas\\PMPL\\testinggoatch1-3\\lists\\urls.py":[1,2,5]}} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..0ecf0cf236c74c9add827536029313f28d909fd5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py + +.env +db.sqlite3 +/.idea/ +/venv/ +geckodriver.log +virtualenv diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..e8c770f67d007176dfe10def77b0714dd2262a0a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,13 @@ +stages: + - test + +Test: + image: python:3.7 + stage: test + before_script: + - pip3 install --upgrade pip + - pip3 install -r requirements.txt + script: + - python3 manage.py test + tags: + - test diff --git a/README.md b/README.md index 87daeef2839a704d1735de5e66931cc709c62490..5e92afbef319500295745f31284762a9d52241c4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# 1606835595-practice - +1606835595-practice +url Heroku : https://pmpl-kevin-simanjuntak.herokuapp.com/homepage/ diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/functional_tests.py b/functional_tests.py new file mode 100644 index 0000000000000000000000000000000000000000..0c4492dbfcf3265559396a8461bb4cf1fe6daac2 --- /dev/null +++ b/functional_tests.py @@ -0,0 +1,26 @@ +from selenium import webdriver +import unittest + +class NewVisitorTest(unittest.TestCase): + + def setUp(self): + self.browser = webdriver.Firefox() + + def tearDown(self): + self.browser.quit() + + def test_can_start_a_list_and_retrieve_it_later(self): + # Edith has heard about a cool new online to-do app. She goes + # to check out its homepage + self.browser.get('http://localhost:8000/homepage') + + # She notices the page title and header mention to-do lists + body_text = self.browser.find_element_by_tag_name('body').text + self.assertIn('Tutorial PMPL', self.browser.title) + self.assertIn('Kevin Albert Simanjuntak', body_text) + self.assertIn('NPM', body_text) + + # She is invited to enter a to-do item straight away + +if __name__ == '__main__': + unittest.main(warnings='ignore') \ No newline at end of file diff --git a/gitlab-ci.yml b/gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..beeb851f56c427779b2149c5264a54b0fca0086d --- /dev/null +++ b/gitlab-ci.yml @@ -0,0 +1,14 @@ +stages: + - test + +Test: + image: python:3.7 + stage: test + before_script: + - pip3 install --upgrade pip + - pip3 install -r requirements.txt + script: + - python3 manage.py test + - python3 functional_tests.py + tags: + - test diff --git a/lists/__init__.py b/lists/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lists/__pycache__/__init__.cpython-37.pyc b/lists/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c672860f758f0cd9eed1e3d95248be80a1e73254 Binary files /dev/null and b/lists/__pycache__/__init__.cpython-37.pyc differ diff --git a/lists/__pycache__/admin.cpython-37.pyc b/lists/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f33b3c15c67ded74cb6badc03f60b8388b09a4d4 Binary files /dev/null and b/lists/__pycache__/admin.cpython-37.pyc differ diff --git a/lists/__pycache__/models.cpython-37.pyc b/lists/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..20ce025413da3c795f0bcef4dcd82ebc4e3d542f Binary files /dev/null and b/lists/__pycache__/models.cpython-37.pyc differ diff --git a/lists/__pycache__/tests.cpython-37.pyc b/lists/__pycache__/tests.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..89fc02474df93be6380eb68b1e7d219424d2ef57 Binary files /dev/null and b/lists/__pycache__/tests.cpython-37.pyc differ diff --git a/lists/__pycache__/urls.cpython-37.pyc b/lists/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..66a36a8f9d5afcde9b119af05682e5687d11797c Binary files /dev/null and b/lists/__pycache__/urls.cpython-37.pyc differ diff --git a/lists/__pycache__/views.cpython-37.pyc b/lists/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3cf9c52c882f69073889ec4c49db7d5150d9e509 Binary files /dev/null and b/lists/__pycache__/views.cpython-37.pyc differ diff --git a/lists/admin.py b/lists/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..8c38f3f3dad51e4585f3984282c2a4bec5349c1e --- /dev/null +++ b/lists/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/lists/apps.py b/lists/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..efe43f03b32216436c4e15becbab60ef7d342598 --- /dev/null +++ b/lists/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ListsConfig(AppConfig): + name = 'lists' diff --git a/lists/migrations/__init__.py b/lists/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lists/migrations/__pycache__/__init__.cpython-37.pyc b/lists/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..033e85318e4066e0c29eb7cc9e2ba52e1e6a5947 Binary files /dev/null and b/lists/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/lists/models.py b/lists/models.py new file mode 100644 index 0000000000000000000000000000000000000000..71a836239075aa6e6e4ecb700e9c42c95c022d91 --- /dev/null +++ b/lists/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/lists/templates/homepage.html b/lists/templates/homepage.html new file mode 100644 index 0000000000000000000000000000000000000000..6417b223312bcf5f6fc01f8ec9699cf0e1f87008 --- /dev/null +++ b/lists/templates/homepage.html @@ -0,0 +1,10 @@ +<html> +<head> + <meta charset="UTF-8"> + <title>Tutorial PMPL</title> +</head> +<body> + <h1>Name: {{ name }}</h1> + <h2> NPM: {{npm}} </h2> +</body> +</html> \ No newline at end of file diff --git a/lists/tests.py b/lists/tests.py new file mode 100644 index 0000000000000000000000000000000000000000..049a01f43cce358f3c8794a9d967ece0d5a70ec3 --- /dev/null +++ b/lists/tests.py @@ -0,0 +1,23 @@ +from django.urls import resolve +from django.test import TestCase +from django.http import HttpRequest +from django.test import Client +from lists.views import home_page + +class HomePageTest(TestCase): + def test_home_page_is_exist(self): + response = Client().get('/homepage/') + self.assertEqual(response.status_code,200) + + def test_root_url_resolves_to_home_page_view(self): + found = resolve('/homepage/') + self.assertEqual(found.func, home_page) + + def test_home_page_returns_correct_html(self): + request = HttpRequest() + response = home_page(request) + html = response.content.decode('utf8') + self.assertTrue(html.startswith('<html>')) + self.assertIn('<title>Tutorial PMPL</title>', html) + self.assertIn('Kevin Albert Simanjuntak', html) + self.assertTrue(html.endswith('</html>')) \ No newline at end of file diff --git a/lists/urls.py b/lists/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..afdcfc3f096bf46750d96b7cf82b04d60138b09a --- /dev/null +++ b/lists/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from .views import home_page +#url for app +urlpatterns = [ + url(r'^$', home_page, name='home_page'), +] diff --git a/lists/views.py b/lists/views.py new file mode 100644 index 0000000000000000000000000000000000000000..01c479fbedd9062c7eab889e442b19517ce6fccd --- /dev/null +++ b/lists/views.py @@ -0,0 +1,9 @@ +from django.http import HttpResponse +from django.shortcuts import render + +# Create your views here. +name = "Kevin Albert Simanjuntak" +npm = "1606835595" +def home_page(request): + response = {"name" : name, "npm" : npm} + return render(request, 'homepage.html', response) \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 0000000000000000000000000000000000000000..3ce678b5b61551ffd732575a8a56b3fcc2a61892 --- /dev/null +++ b/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..b3e8f1480f9db43db44103f031d41083d93e9986 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +Django==2.2.5 +pytz==2019.2 +selenium==3.141.0 +sqlparse==0.3.0 +urllib3==1.25.3 +whitenoise==3.3.0 \ No newline at end of file diff --git a/superlists/__init__.py b/superlists/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/superlists/__pycache__/__init__.cpython-37.pyc b/superlists/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..332596cec1001e124f8ed848299be52d9ff65525 Binary files /dev/null and b/superlists/__pycache__/__init__.cpython-37.pyc differ diff --git a/superlists/__pycache__/settings.cpython-37.pyc b/superlists/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e77811427d9c38c0dace3fdf45f84b2ded0b8c65 Binary files /dev/null and b/superlists/__pycache__/settings.cpython-37.pyc differ diff --git a/superlists/__pycache__/urls.cpython-37.pyc b/superlists/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..943d5be1c73db4c21ad341545ef82ca68c8ec4d9 Binary files /dev/null and b/superlists/__pycache__/urls.cpython-37.pyc differ diff --git a/superlists/__pycache__/wsgi.cpython-37.pyc b/superlists/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1c06f2bd8346136da20582177971050ee454622e Binary files /dev/null and b/superlists/__pycache__/wsgi.cpython-37.pyc differ diff --git a/superlists/settings.py b/superlists/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..6af5cd6287b89449131bc4ba94fd719a02ff75b0 --- /dev/null +++ b/superlists/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for superlists project. + +Generated by 'django-admin startproject' using Django 2.0. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) +ALLOWED_HOSTS = ['*'] + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'bmgr4@$g#+(o=tp7l(_=&ca3s6o*gul%8j@arvh^+-%b)rhtni' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'lists' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'superlists.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'superlists.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.0/howto/static-files/ +STATIC_URL = '/static/' +STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') diff --git a/superlists/urls.py b/superlists/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..0cba3cacc10e12bbc75d4932785524eea29e5bee --- /dev/null +++ b/superlists/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import url, include +from lists import views +import lists.urls as lists + +urlpatterns = [ + #url(r'^$', views.home_page, name='home'), + url(r'^homepage/', include(('lists.urls', 'lists'),namespace='lists')), + +] \ No newline at end of file diff --git a/superlists/wsgi.py b/superlists/wsgi.py new file mode 100644 index 0000000000000000000000000000000000000000..983703fa404b1cd524feb2d36a7bba2a795d0810 --- /dev/null +++ b/superlists/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for superlists project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings") + +application = get_wsgi_application()