Skip to content

Commit 157a364

Browse files
Merge pull request #503 from moevm/494_selenium+docker
494 selenium+docker
2 parents 727e18c + 92e8968 commit 157a364

29 files changed

+492
-26
lines changed

.env_example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ CONSUMER_SECRET=secret
1010
WEB_PORT=8080
1111

1212
REDIS_URL=redis://redis:6379/0
13-
CELERY_QUERIES=query
13+
CELERY_QUERIES=check-solution
1414

1515
FLOWER_SECRET_KEY=123
1616
FLOWER_PORT=5555
1717
FLOWER_AUTH=user:user
1818
FLOWER_PREFIX=/
1919

20-
MONGODB_CACHE_SIZE=1
20+
MONGODB_CACHE_SIZE=1
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Selenium_tests
2+
3+
on: [push]
4+
5+
jobs:
6+
check_tests:
7+
runs-on: ubuntu-20.04
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Build docker-compose with docker-compose-selenium (tests)
13+
run: |
14+
cp .env_example .env
15+
cp app/VERSION_example.json app/VERSION.json
16+
docker-compose -f docker-compose.yml -f docker-compose-selenium.yml build
17+
18+
- name: Run docker-compose with docker-compose-selenium (tests)
19+
run: |
20+
docker-compose -f docker-compose.yml -f docker-compose-selenium.yml up -d
21+
chmod +x tests/scripts/docker_check_tests.sh
22+
./tests/scripts/docker_check_tests.sh
23+
24+
25+
# jobs:
26+
# check_tests:
27+
# runs-on: ubuntu-20.04
28+
29+
# steps:
30+
# - uses: actions/checkout@v2
31+
32+
# - name: Simplify docker-compose file name
33+
# run: mv docker-compose-tests.yml docker-compose.yml
34+
35+
# - name: Build system images (non-pulling)
36+
# run: |
37+
# # build base image
38+
# docker build -f Dockerfile_base -t osll/slides-base:20230202 .
39+
40+
# - name: Run docker-compose tests
41+
# run: |
42+
# cp .env_example .env
43+
# docker-compose up -d
44+
# chmod +x tests/scripts/docker_check_tests.sh
45+
# ./tests/scripts/docker_check_tests.sh

Dockerfile_selenium

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM selenium/standalone-chrome:121.0-chromedriver-121.0-grid-4.18.0-20240220
2+
3+
ENV LOGIN=""
4+
ENV PASSWORD=""
5+
6+
WORKDIR /usr/src/project
7+
8+
USER root
9+
RUN apt-get update && \
10+
apt-get install -y python3 python3-pip && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
COPY tests/requirements.txt tests/requirements.txt
14+
RUN pip install -r tests/requirements.txt
15+
COPY tests ./tests
16+
17+
ENTRYPOINT python3 tests/main.py --login ${LOGIN} --password ${PASSWORD}

app/VERSION_example.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "",
3+
"message": "",
4+
"date": "",
5+
"version": ""
6+
}

app/main/checks/report_checks/needed_headers_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def late_init(self):
2323
self.headers = self.file.make_chapters(self.file_type['report_type'])
2424
self.headers_page = self.file.find_header_page(self.file_type['report_type'])
2525
self.chapters_str = self.file.show_chapters(self.file_type['report_type'])
26-
self.headers_main = self.file.get_main_headers()
2726
# TODO: change
27+
self.headers_main = self.file.get_main_headers(self.file_type['report_type'])
2828
if self.headers_main == "Задание 1":
2929
self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[0]["headers"]
3030
elif self.headers_main == "Задание 2":

app/main/reports/document_uploader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ def find_literature_page(self, work_type):
4848
@abstractmethod
4949
def show_chapters(self, work_type):
5050
pass
51+
52+
def get_main_headers(self):
53+
pass

app/main/reports/docx_uploader/docx_uploader.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self):
1818
self.inline_shapes = []
1919
self.core_properties = None
2020
self.headers = []
21+
self.headers_main = ''
2122
self.file = None
2223
self.special_paragraph_indices = {}
2324
self.headers_page = 0
@@ -90,6 +91,12 @@ def make_headers(self, work_type):
9091
break
9192
self.headers = headers
9293
return self.headers
94+
95+
def get_main_headers(self, work_type): #this method helps to avoid mistake in "needed_headers_check" (because of structure checks for md)
96+
if not self.headers_main:
97+
if work_type == 'VKR':
98+
self.headers_main = self.make_headers(work_type)[1]['name']
99+
return self.headers_main
93100

94101
def __make_table(self, tables):
95102
for i in range(len(tables)):

app/main/reports/md_uploader/md_uploader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def page_counter(self): # we need this just to find a last page and make link to
9595
self.page_count = 5
9696
return self.page_count
9797

98-
def get_main_headers(self):
98+
def get_main_headers(self, work_type):
9999
if not self.headers_main:
100100
header_main_regex = "<h1>(.*?)<\/h1>"
101101
self.headers_main = re.findall(header_main_regex, self.html_text)[0]

app/nlp/stemming.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import itertools
2-
3-
import nltk
42
from nltk.corpus import stopwords
53
from nltk.tokenize import word_tokenize, sent_tokenize
64
from pymorphy2 import MorphAnalyzer
75

8-
nltk.download('stopwords')
9-
nltk.download('punkt')
106

117
MORPH_ANALYZER = MorphAnalyzer()
128
TASKS = 'задачи:'

app/tasks.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import configparser
1+
from configparser import ConfigParser
22
import os
33
from os.path import join, exists
44

55
from celery import Celery
6+
from celery.signals import worker_ready
67

7-
import passback_grades
8+
from passback_grades import run_passback
89
from db import db_methods
910
from db.db_types import Check
1011
from main.checker import check
1112
from main.parser import parse
1213
from main.check_packs import BASE_PACKS
1314
from root_logger import get_root_logger
1415

15-
config = configparser.ConfigParser()
16+
config = ConfigParser()
1617
config.read('app/config.ini')
1718

1819
TASK_RETRY_COUNTDOWN = 60 # default = 3 * 60
@@ -33,6 +34,16 @@
3334
celery.conf.timezone = 'Europe/Moscow' # todo: get from env
3435

3536

37+
@worker_ready.connect
38+
def at_start(sender, **k):
39+
from nltk import download
40+
download('stopwords')
41+
download('punkt')
42+
43+
from language_tool_python.download_lt import download_lt
44+
download_lt()
45+
46+
3647
@celery.task(name="create_task", queue='check-solution', bind=True)
3748
def create_task(self, check_info):
3849
check_obj = Check(check_info)
@@ -67,12 +78,11 @@ def create_task(self, check_info):
6778
self.retry(countdown=TASK_RETRY_COUNTDOWN) # Retry the task, adding it to the back of the queue.
6879

6980

81+
@celery.task(name="passback-task", queue='passback-grade')
82+
def passback_task():
83+
return run_passback()
84+
85+
7086
def remove_files(filepaths):
7187
for filepath in filepaths:
7288
if exists(filepath): os.remove(filepath)
73-
74-
75-
@celery.task(name="passback-task", queue='passback-grade')
76-
def passback_task():
77-
print('Run passback')
78-
return passback_grades.run_passback()

0 commit comments

Comments
 (0)