diff --git a/.gitignore b/.gitignore index c4579e46cc6aa3e4ee98e10fa0a41d6699a726be..6daad418c8e14da77357691dcbde4cd3dd984a44 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ __pycache__ *.pyc .vscode /staticfiles -db.sqlite3 \ No newline at end of file +db.sqlite3 +.coverage diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 246597c2e1ee376c785b5a20da35051f9a61f671..a29fd5972feab07d97b1456e1a11a3bbcf802655 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,24 @@ +image: alpine:latest + stages: - - deploy + - test + +services: + - postgres:latest -Deployment: - image: ruby:2.4 - stage: deploy +variables: + POSTGRES_DB: database + POSTGRES_USER: postgres + POSTGRES_PASSWORD: "password" + +Testing: + stage: test + image: joyzoursky/python-chromedriver:3.7 before_script: - - gem install dpl - - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh + - pip install -r requirements.txt + - export DB_HOST=postgres + - python manage.py collectstatic + - python manage.py migrate script: - - dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY - - export HEROKU_API_KEY=$HEROKU_APIKEY - - heroku run --app $HEROKU_APPNAME migrate - environment: - name: production - url: $HEROKU_APP_HOST - + - coverage run --source=accounts,lists manage.py test + - coverage report -m diff --git a/README.md b/README.md index 742194bb249d4a273883c63232581f5d22e241da..a56f198d6794704730f6fb1893e2e240a17db8c1 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ PMPL Course - Class A URL: http://pmpl-rayza.herokuapp.com +[](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606876052-practice/commits/master) + +[](https://gitlab.cs.ui.ac.id/pmpl/practice-collection/2019/1606876052-practice/commits/master) + ## Exercise - 3 : Test Isolation diff --git a/chromedriver b/chromedriver new file mode 100755 index 0000000000000000000000000000000000000000..eeecd35954ba5fd390b0dadd83c2890b160ce259 Binary files /dev/null and b/chromedriver differ diff --git a/functional_tests/base.py b/functional_tests/base.py index 8e6505ec86d50b24bfd193ac46a1a1a2226d30cd..c216c2adb959458c220977f2f0011168639d48f3 100644 --- a/functional_tests/base.py +++ b/functional_tests/base.py @@ -8,8 +8,24 @@ MAX_WAIT = 10 class FunctionalTest(StaticLiveServerTestCase): + def get_browser(self): + desired_capabilities = webdriver.DesiredCapabilities.CHROME + desired_capabilities['loggingPrefs'] = {'browser': 'ALL'} + + chrome_options = webdriver.ChromeOptions() + chrome_options.add_argument('--no-sandbox') + chrome_options.add_argument('--headless') + chrome_options.add_argument('--disable-gpu') + + desired_capabilities.update(chrome_options.to_capabilities()) + + browser = webdriver.Chrome('./chromedriver', desired_capabilities=desired_capabilities) + + return browser + + def setUp(self): - self.browser = webdriver.Firefox() + self.browser = self.get_browser() self.browser.implicitly_wait(3) def tearDown(self): diff --git a/functional_tests/test_simple_list_creation.py b/functional_tests/test_simple_list_creation.py index c499223f56e5bf82a25dfb7864ce3f5d1c64efd3..50a42861bed394e45707f9ebbb6bb93acc0c391c 100644 --- a/functional_tests/test_simple_list_creation.py +++ b/functional_tests/test_simple_list_creation.py @@ -70,7 +70,7 @@ class NewVisitorTest(FunctionalTest): ## We use a new browser session to make sure that no information ## of Edith's is coming through from cookies etc self.browser.quit() - self.browser = webdriver.Firefox() + self.browser = self.get_browser() # Francis visits the home page. There is no sign of Edits's # list diff --git a/requirements.txt b/requirements.txt index f523d598bd7d53ef5b6f9c972c4e587b01979ea4..814dc450af85d39d4321914d62712d3a65c823fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ astmonkey==0.3.6 +coverage==5.0.1 dj-database-url==0.5.0 Django==2.2.5 django-heroku==0.3.1 diff --git a/superlists/settings.py b/superlists/settings.py index 0e9eeb9158da6e9bfd37c93879ef759fb8fe04ea..c60ddcf99a29676bbe7db7ba2b8c82c437191c56 100644 --- a/superlists/settings.py +++ b/superlists/settings.py @@ -98,7 +98,7 @@ DATABASES = { 'NAME': os.environ.get('DB_NAME', ''), 'USER': os.environ.get('DB_USER', ''), 'PASSWORD': os.environ.get('DB_PASS', ''), - 'HOST': 'localhost', + 'HOST': os.environ.get('DB_HOST', 'localhost'), 'PORT': '5432', } }