Fakultas Ilmu Komputer UI

Commit 9f4787ee authored by jordan's avatar jordan
Browse files

fixing pipeline

parent 785b1200
Pipeline #27752 failed with stages
in 1 minute and 17 seconds
File added
[run]
source =
lists
accounts
omit =
*/__init__.py
*/apps.py
*/admin.py
/management/
/migrations/
[report]
omit =
*/__init__.py
*/apps.py
*/admin.py
/management/
/migrations/
\ No newline at end of file
stages:
- unitTest
- deploy
- functionalTest
UnitTest:
image: python:3.7
stage: unitTest
before_script:
- pip3 install -r requirements.txt
script:
- python3 manage.py muttest lists --modules lists.views
- coverage run manage.py test lists accounts
- coverage report -m
Deploy:
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 run --app $HEROKU_APPNAME python manage.py migrate
environment:
name: production
url: $HEROKU_APP_HOST
only:
- master
FunctionalTest:
image: python:3.7
stage: functionalTest
dependencies:
- Deploy
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
- 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
- pip3 install -r requirements.txt
- python3 manage.py migrate --noinput
- python3 manage.py test functional_tests
when: on_success
script:
- echo "Functional Test OK"
only:
- master
- uastakehomeprogramming
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
......@@ -11,26 +11,26 @@ class SendLoginEmailViewTest(TestCase):
)
self.assertRedirects(response, "/")
def test_sends_mail_to_address_from_post(self):
self.send_mail_called = False
def fake_send_mail(subject, body, from_email, to_list):
self.send_mail_called = True
self.subject = subject
self.body = body
self.from_email = from_email
self.to_list = to_list
accounts.views.send_mail = fake_send_mail
self.client.post(
"/accounts/send_login_email", data={"email": "edith@example.com"}
)
self.assertTrue(self.send_mail_called)
self.assertEqual(self.subject, "Your login link for Superlists")
self.assertEqual(self.from_email, "noreply@superlists")
self.assertEqual(self.to_list, ["edith@example.com"])
# def test_sends_mail_to_address_from_post(self):
# self.send_mail_called = False
# def fake_send_mail(subject, body, from_email, to_list):
# self.send_mail_called = True
# self.subject = subject
# self.body = body
# self.from_email = from_email
# self.to_list = to_list
# accounts.views.send_mail = fake_send_mail
# self.client.post(
# "/accounts/send_login_email", data={"email": "edith@example.com"}
# )
# self.assertTrue(self.send_mail_called)
# self.assertEqual(self.subject, "Your login link for Superlists")
# self.assertEqual(self.from_email, "noreply@superlists")
# self.assertEqual(self.to_list, ["edith@example.com"])
@patch("accounts.views.send_mail")
def test_sends_mail_to_address_from_post(self, mock_send_mail):
......
from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
from lists.views import home_page
from lists.views import home_page, get_comment
from lists.models import Item, List
from django.template.loader import render_to_string
......@@ -115,3 +115,26 @@ class NewItemTest(TestCase):
data={"item_text": "A new item for an existing list"},
)
self.assertRedirects(response, "/lists/%d/" % (correct_list.id,))
def test_view_list(self):
other_list = List.objects.create()
correct_list = List.objects.create()
response = self.client.post(
"/lists/%d/" % (correct_list.id,)
)
self.assertTemplateUsed(response, "list.html")
class GenereateCommentTest(TestCase):
def test_message_sibuk_santai(self):
result = get_comment(1)
self.assertEqual(result, 'sibuk tapi santai')
def test_message_waktunya_libur(self):
result = get_comment(0)
self.assertEqual(result, "yey, waktunya berlibur")
def test_message_oh_tidak(self):
result = get_comment(5)
self.assertEqual(result, "oh tidak")
......@@ -18,10 +18,10 @@ def home_page(request):
# {'items': items, 'comment': comment}
def view_list(request, list_id):
list_ = List.objects.get(id=list_id)
items = Item.objects.filter(list=list_)
return render(request, "list.html", {"items": items})
# def view_list(request, list_id):
# list_ = List.objects.get(id=list_id)
# items = Item.objects.filter(list=list_)
# return render(request, "list.html", {"items": items})
def new_list(request):
......@@ -40,12 +40,6 @@ def view_list(request, list_id):
list_ = List.objects.get(id=list_id)
return render(request, "list.html", {"list": list_})
def test_redirects_after_POST(self):
response = self.client.post("/lists/new", data={"item_text": "A new list item"})
self.assertRedirects(response, "/lists/the-only-list-in-the-world/")
def get_comment(count):
if count == 0:
comment = "yey, waktunya berlibur"
......
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