Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spm spring2021 2597 蓝嘉婕201831990605 #8

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
44434c7
Fix clicking the ANSWER button will add the selected words repeatedly
CNZedChou Jun 7, 2021
df78a95
Docker image for flask web applications in py 3.6 and above
CNZedChou Jun 8, 2021
685c9fb
Jenkinsfile update with test and deploy stage under construction
CNZedChou Jun 10, 2021
589a331
Add a test script version 1.0 for our bug fix assignment
CNZedChou Jun 10, 2021
44284bb
Update jenkinsfile for test stage
CNZedChou Jun 10, 2021
4c1da1c
Port update in jenkinsfile
CNZedChou Jun 10, 2021
2095051
Update gitignore file
CNZedChou Jun 10, 2021
4f80124
Update gitignore file
CNZedChou Jun 10, 2021
21bac14
Merge remote-tracking branch 'remotes/origin/master' into SPM-Spring2…
CNZedChou Jun 10, 2021
f9b32c0
update test script method name
CNZedChou Jun 10, 2021
2d861c3
The result of the xpath expression should be an element
CNZedChou Jun 10, 2021
d89e1a1
fix bug
CNZedChou Jun 10, 2021
e14b372
test script version 1.1
CNZedChou Jun 10, 2021
d20f6ef
test script version 2.0, use ActionChains to perform mouse actions, o…
CNZedChou Jun 10, 2021
83d3122
modify jenkinsfile which should be merged from master
CNZedChou Jun 10, 2021
fd09364
update the way how test script get essay content, more reasonable now
CNZedChou Jun 10, 2021
7469074
fix bug of index error
CNZedChou Jun 10, 2021
edff5a7
Update Jenkinsfile
CNZedChou Jun 10, 2021
63b30eb
Update Jenkinsfile
CNZedChou Jun 11, 2021
ef4a724
Update Jenkinsfile
CNZedChou Jun 11, 2021
8691fbd
this file contains the link to our demonstration video
CNZedChou Jun 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ app/static/frequency/frequency.p
app/static/wordfreqapp.db
app/static/donate-the-author.jpg
app/static/donate-the-author-hidden.jpg
.idea/.gitignore
.idea/EnglishPal.iml
.idea/inspectionProfiles/
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml
app/.idea/.gitignore
app/.idea/app.iml
app/.idea/inspectionProfiles/
app/.idea/misc.xml
app/.idea/modules.xml
app/.idea/vcs.xml
app/test/.cache/

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM tiangolo/uwsgi-nginx-flask:python3.6
FROM tiangolo/uwsgi-nginx-flask:python3.8

COPY ./app /app
32 changes: 17 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
pipeline {
agent any

stages {
agent any
parameters {
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'SPM-Spring2021-2597-蓝嘉婕201831990605', name: 'BRANCH', type: 'PT_BRANCH'
}
stages {
stage('MakeDatabasefile') {
steps {
sh 'touch ./app/static/wordfreqapp.db && rm -f ./app/static/wordfreqapp.db'
sh 'cat ./app/static/wordfreqapp.sql | sqlite3 ./app/static/wordfreqapp.db'
steps {
sh 'touch ./app/static/wordfreqapp.db && rm -f ./app/static/wordfreqapp.db'
sh 'cat ./app/static/wordfreqapp.sql | sqlite3 ./app/static/wordfreqapp.db'
}
}
}
stage('BuildIt') {
steps {
echo 'Building..'
sh 'sudo docker build -t englishpal .'
sh 'sudo docker stop $(docker ps -aq)'
sh 'sudo docker run -d -p 91:80 -v /var/lib/jenkins/workspace/EnglishPal_Pipeline_master/app/static/frequency:/app/static/frequency -t englishpal'
sh 'sudo docker build -t englishpal .'
sh 'sudo docker stop $(docker ps -aq)'
sh 'sudo docker run -d -p 91:80 -v /var/lib/jenkins/workspace/EnglishPal_Pipeline_master/app/static/frequency:/app/static/frequency -t englishpal'
}
}
stage('TestIt') {
steps {
echo 'Testing..'
sh 'sudo docker run -d -p 4444:4444 selenium/standalone-chrome'
sh 'pip3 install pytest -U -q'
sh 'pip3 install selenium -U -q'
sh 'pytest -v -s --html=EnglishPalTestReport.html ./app/test'
sh 'sudo docker run -d -p 4444:4444 selenium/standalone-chrome'
sh 'pip3 install pytest -U -q'
sh 'pip3 install selenium -U -q'
sh 'pytest -v -s --html=EnglishPalTestReport.html ./app/test'
}
}
stage('DeployIt') {
steps {
echo 'Deploying (TBD)'
echo 'Under Construction....'
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def get_answer_part(s):
<script type="text/javascript">

function toggle_visibility(id) {
window.getSelection().empty()
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
Expand Down
3 changes: 1 addition & 2 deletions app/test/test_add_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def test_add_word():
assert 'EnglishPal Study Room for ' + uname in driver.title

# get essay content
elem = driver.find_element_by_id('text-content')
essay_content = elem.text
essay_content = driver.find_elements_by_xpath('/html/body/div/p[3]/font')[0].text

elem = driver.find_element_by_id('selected-words')
word = random.choice(essay_content.split())
Expand Down
7 changes: 4 additions & 3 deletions app/test/test_add_word_and_essay_does_not_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ def test_add_word_and_essay_does_not_change():

# get essay content
driver.save_screenshot('./app/test/test_add_word_and_essay_does_not_change_pic0.png')
article_content = driver.find_elements_by_xpath('/html/body/div/p[3]/font')[0].text
elem = driver.find_element_by_id('text-content')
essay_content = elem.text

elem = driver.find_element_by_id('selected-words')
word = random.choice(essay_content.split())
word = random.choice(article_content.split())
while 'font>' in word or 'br>' in word or 'p>' in word or len(word) < 5 or has_punctuation(word):
word = random.choice(essay_content.split())
word = random.choice(article_content.split())
elem.send_keys(word)
elem = driver.find_element_by_xpath('//form[1]//input[1]') # 找到get所有词频按钮
elem.click()
Expand Down
56 changes: 56 additions & 0 deletions app/test/test_fix_click_answer_bug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
# Run the docker image using the following command:
# docker run -d -p 4444:4444 selenium/standalone-chrome
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver import ActionChains
import random, time
import string

driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME)
driver.implicitly_wait(10)

HOME_PAGE = 'http://121.4.94.30:91/'


def has_punctuation(s):
return [c for c in s if c in string.punctuation] != []


def test_fix_click_answer_bug():
try:
driver.get(HOME_PAGE)
assert 'English Pal -' in driver.page_source

# login
elem = driver.find_element_by_link_text('登录')
elem.click()

uname = 'lanhui'
password = 'l0ve1t'
elem = driver.find_element_by_name('username')
elem.send_keys(uname)

elem = driver.find_element_by_name('password')
elem.send_keys(password)

elem = driver.find_element_by_xpath('//form[1]/p[3]/input[1]') # 找到登录按钮
elem.click()

assert 'EnglishPal Study Room for ' + uname in driver.title

# get essay content
elem = driver.find_element_by_xpath("/html/body/div/p[3]/font")
ActionChains(driver).double_click(elem).perform()
#find answer button, and click it twice
answer = driver.find_element_by_xpath('/html/body/div/button')
answer.click()
answer.click()

elem = driver.find_element_by_xpath('//form[1]//input[1]') # 找到get所有词频按钮
elem.click()

preq = driver.find_element_by_xpath('/html/body/form/p[1]')
assert preq.text.split()[2] == '(1)'
finally:
driver.quit()
3 changes: 1 addition & 2 deletions app/test/test_next_essay.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def test_next():

# get essay content
driver.save_screenshot('./app/test/test_next_essay_pic0.png')
elem = driver.find_element_by_id('text-content')
essay_content = elem.text
essay_content = driver.find_elements_by_xpath('/html/body/div/p[3]/font')[0].text

# click Next
diff = 0
Expand Down
1 change: 1 addition & 0 deletions video_link.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
link to our Demonstration video : https://www.bilibili.com/video/BV1G5411u7Gc