Skip to content

Commit

Permalink
trying to run git actions first time
Browse files Browse the repository at this point in the history
  • Loading branch information
MueezKhan246 committed Jan 11, 2022
1 parent 0b5be98 commit cda93d6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 59 deletions.
34 changes: 9 additions & 25 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]


jobs:
build:

runs-on: ubuntu-latest

steps:
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Install dependencies
run: /
python -m pip install --upgrade zip
if [ -f requirements.txt ]; tehn pip install -r requirements.txt; fi
- name: Test selenium
run: /
python manage.py test
Binary file modified __pycache__/test.cpython-39.pyc
Binary file not shown.
Binary file modified db.sqlite3
Binary file not shown.
76 changes: 44 additions & 32 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,56 @@
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from django.contrib.auth.models import User
import time
import django

class Hosttest(LiveServerTestCase):

def testhomepage(self):

class LoginFormTest(LiveServerTestCase):
options = Options()
options.headless = True
driver = webdriver.Chrome(options=options)

driver.get(self.live_server_url)
# try driver.get(self.live_server_url) if driver.get('http://127.0.0.1:8000/') does not work

assert "Hello, world!" in driver.title

# class LoginFormTest(LiveServerTestCase):


port = 8000
host = '127.0.0.1'
def setUp(self):
self.selenium = webdriver.Chrome(executable_path="/Users/mueezkhan/django-test/chromedriver")
super(LoginFormTest, self).setUp()
# port = 8000
# host = '127.0.0.1'
# def setUp(self):
# self.selenium = webdriver.Chrome(executable_path="/Users/mueezkhan/django-test/chromedriver")
# super(LoginFormTest, self).setUp()


def tearDown(self):
self.selenium.quit()
super(LoginFormTest, self).tearDown()
# def tearDown(self):
# self.selenium.quit()
# super(LoginFormTest, self).tearDown()

def testform(self):
driver = self.selenium
# super(LoginFormTest, self).setUp()
driver.get(f"http://127.0.0.1:8000/accounts/login")

# user = User.objects.create_user('kamil', '[email protected]', 'kamil')

# print(user)
# time.sleep(1)
user_name = driver.find_element_by_name('username')
user_password = driver.find_element_by_name('password')
time.sleep(3)
submit = driver.find_element_by_id('submit')

user_name.send_keys('kamil')
user_password.send_keys('kamil')

submit.send_keys(Keys.RETURN)
time.sleep(3)
print(driver.page_source)
assert 'kamil' in driver.page_source
# def testform(self):
# driver = self.selenium
# # super(LoginFormTest, self).setUp()
# driver.get(f"http://127.0.0.1:8000/accounts/login")

# # user = User.objects.create_user('kamil', '[email protected]', 'kamil')

# # print(user)
# # time.sleep(1)
# user_name = driver.find_element_by_name('username')
# user_password = driver.find_element_by_name('password')
# time.sleep(3)
# submit = driver.find_element_by_id('submit')

# user_name.send_keys('kamil')
# user_password.send_keys('kamil')

# submit.send_keys(Keys.RETURN)
# time.sleep(3)
# print(driver.page_source)
# assert 'kamil' in driver.page_source

Binary file modified test_basic/__pycache__/settings.cpython-39.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions test_basic/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
# 'TEST': {
# 'USER': 'kamil',
# 'PASSWORD': 'kamil',
# # 'USER': 'kamil',
# # 'PASSWORD': 'kamil',
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3'
# }
}
Expand Down

0 comments on commit cda93d6

Please sign in to comment.