Fakultas Ilmu Komputer UI

Commit 56ddf270 authored by Michael Christopher Manullang's avatar Michael Christopher Manullang
Browse files

Adjusted location of functional test

parent efc571b5
Pipeline #58067 failed with stages
in 18 minutes and 10 seconds
......@@ -18,42 +18,6 @@ pylint:
paths:
- ./pylint/
functional-test:
image: ubuntu:latest
stage: test
services:
- postgres:alpine
variables:
POSTGRES_DB: gitlab_test
POSTGRES_USER: gitlab_test
POSTGRES_PASSWORD: SebuahPassword
POSTGRES_HOST_AUTH_METHOD: trust
before_script:
- apt-get update -qq
- apt-get install -qq software-properties-common
- apt-add-repository universe
- add-apt-repository ppa:deadsnakes/ppa
- apt update
- apt-get install -qq python3.7
- apt-get install -qq python3-pip
- pip3 install virtualenv
- virtualenv env
- source env/bin/activate
- export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_DB
- pip3 install -r requirements.txt
- python3 manage.py makemigrations
- python3 manage.py migrate
- python3 manage.py collectstatic --no-input
- apt-get install -qq firefox
- apt install -qq curl -y
- curl -L -O https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz
- tar -xf geckodriver-v0.27.0-linux64.tar.gz -C /usr/local/bin
- chmod +x /usr/local/bin/geckodriver
when: on_success
script:
- python manage.py runserver && python3 functional_tests.py
allow_failure: true
UnitTest:
services:
- postgres:alpine
......
......@@ -20,6 +20,14 @@ from .views import (DaftarKatalog, DashboardKontributorView, DetailMateri,
from app.views import UploadMateriHTML, UploadMateriView
from authentication.models import User
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import NoSuchElementException
class DaftarKatalogTest(TestCase):
def test_daftar_katalog_url_exist(self):
......@@ -929,17 +937,36 @@ class RevisiMateriTest(TestCase):
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
#from selenium import webdriver
#class NameBannerFunctionalTest(TestCase):
# browser = webdriver.Firefox()
# #I visit the homepage
# browser.get('http://localhost:8000')
# #I see a namebanner
# assert 'navbar' in browser
# #The namebanner has digipus on it
# assert 'Digipus' in browser.body.navbar
# browser.quit()
class NameBannerFunctionalTest(LiveServerTestCase):
selenium = None
@classmethod
def setUpClass(cls):
super().setUpClass()
options = Options()
options.add_argument('--headless')
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_argument("--no-sandbox")
cls.selenium = webdriver.Chrome(ChromeDriverManager().install(),
chrome_options=options)
cls.selenium.implicitly_wait(10)
@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()
def test_list_todo_available(self):
self.selenium.get(f'{self.live_server_url}')
try:
self.assertIn('Digipus', self.selenium.find_element_by_css_selector('nav.katalog-navbar').text)
except NoSuchElementException:
self.fail('No such element: Katalog Brand')
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import unittest
from selenium.common.exceptions import NoSuchElementException
class NavbarKatalogFunctionalTests(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def tearDown(self):
self.browser.quit()
def test_title_is_michael_christopher_manullang(self):
#Ketika Pengguna mengakses web page, ia akan menemukan navbar yang berisikan digipus.
self.browser.get('http://127.0.0.1:8000')
try:
self.assertIn('Digipus', self.browser.find_element_by_css_selector('nav.katalog-navbar').text)
except NoSuchElementException:
self.fail('No such element: Katalog Brand')
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
......@@ -16,7 +16,9 @@ cfgv==3.1.0
chardet==3.0.4
click==7.1.1
colorama==0.4.3
configparser==5.0.1
coverage==5.0.4
crayons==0.4.0
cryptography==2.9.2
distlib==0.3.0
dj-database-url==0.5.0
......@@ -82,6 +84,7 @@ typed-ast==1.4.1
urllib3==1.25.9
virtualenv==20.0.18
wcwidth==0.1.9
webdriver-manager==3.2.2
whitenoise==5.0.1
wrapt==1.11.2
zipp==3.1.0
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