Merge branch 'master' into feature/replace-react-to-vue-add-login-panel

This commit is contained in:
Tomasz F 2021-04-22 16:11:58 +02:00 committed by GitHub
commit 2389eb28ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 157 additions and 18 deletions

View file

@ -1,38 +1,51 @@
# Wulkanowy-web # Wulkanowy Web
🌋 Unofficial browser VULCAN UONET+ client for both students and their parents
🌋 Unofficial VULCAN UONET+ browser client for students and their parents
![GitHub Workflow Status](https://github.com/wulkanowy/wulkanowy-web/workflows/Python%20application/badge.svg) ![GitHub Workflow Status](https://github.com/wulkanowy/wulkanowy-web/workflows/Python%20application/badge.svg)
[![Discord](https://img.shields.io/discord/390889354199040011.svg?color=#33CD56)](https://discord.gg/vccAQBr)
## Join our Discord server!
[![Discord](https://discordapp.com/api/guilds/390889354199040011/widget.png?style=banner2)](https://discord.com/invite/vccAQBr)
# Development # Development
## 1. Install dependencies.
```shell ## 1. Install dependencies
```sh
pip install -r requirements.txt pip install -r requirements.txt
npm i
``` ```
And in frontend:
```shell
npm install
```
## 2. Make migrations ## 2. Make migrations
```shell
```sh
python manage.py makemigrations python manage.py makemigrations
python manage.py migrate python manage.py migrate
``` ```
## 3. Start the server!
```shell ## 3. Start the server
```sh
python manage.py runserver python manage.py runserver
``` ```
And in frontend: And in frontend:
```shell ```shell
cd frontend
npm run build npm run build
``` ```
# Docker # Docker
## With docker compose
```shell With docker compose
```sh
docker-compose up -d docker-compose up -d
``` ```
## Without docker compose
```shell Without docker compose
```sh
docker build -t wulkanowy/web . docker build -t wulkanowy/web .
docker run -d -p 8000:8000 wulkanowy/web docker run -d -p 8000:8000 wulkanowy/web
```

View file

@ -11,20 +11,35 @@ class TestViews(TestCase):
def test_views(self): def test_views(self):
#DEFAULT_VIEW #DEFAULT_VIEW
print("\033[94mTesting login view...")
response = self.client.get(self.list_url) response = self.client.get(self.list_url)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'frontend/index.html') self.assertTemplateUsed(response, 'frontend/index.html')
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#CONTENT_VIEW #CONTENT_VIEW
print("\033[94mTesting content view...")
response = self.client.get(self.detail_url) response = self.client.get(self.detail_url)
self.assertEquals(response.status_code, 302) self.assertEquals(response.status_code, 302)
if response.status_code == 302:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#ACCOUNT_MANAGER #ACCOUNT_MANAGER
print("\033[94mTesting account manager view...")
response = self.client.get(reverse('account_manager')) response = self.client.get(reverse('account_manager'))
self.assertEquals(response.status_code, 302) self.assertEquals(response.status_code, 302)
if response.status_code == 302:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#API #API
data = { data = {
@ -33,18 +48,29 @@ class TestViews(TestCase):
"Symbol": "powiatwulkanowy", "Symbol": "powiatwulkanowy",
"diaryUrl": "http://cufs.fakelog.cf/" "diaryUrl": "http://cufs.fakelog.cf/"
} }
print("\033[94mTesting login...")
response = self.client.post(reverse('login'), content_type='application/xml', data=json.dumps(data)) response = self.client.post(reverse('login'), content_type='application/xml', data=json.dumps(data))
cookies_data = response.json() cookies_data = response.json()
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
students = cookies_data['data']['students']['data'] students = cookies_data['data']['students']['data']
#JAN #JAN
print("\033[94mTesting as Jan Kowalski...")
print("\033[95m============================================================")
jan_data = students[0] jan_data = students[0]
cookies_data['data']['students']['data'] = [jan_data] cookies_data['data']['students']['data'] = [jan_data]
get_data_test(self.client, cookies_data, self.assertEquals) get_data_test(self.client, cookies_data, self.assertEquals)
print("\033[96m========================================================================")
#JOANNA #JOANNA
print("\033[94mTesting as Joanna Czerwińska...")
print("\033[95m============================================================")
joanna_data = students[3] joanna_data = students[3]
cookies_data['data']['students']['data'] = [joanna_data] cookies_data['data']['students']['data'] = [joanna_data]
get_data_test(self.client, cookies_data, self.assertEquals) get_data_test(self.client, cookies_data, self.assertEquals)
@ -53,83 +79,169 @@ class TestViews(TestCase):
def get_data_test(client, cookies_data, assertEquals): def get_data_test(client, cookies_data, assertEquals):
#GRADES #GRADES
print("\033[94mTesting grades...")
response = client.post(reverse('grades'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('grades'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#TIMETABLE #TIMETABLE
print("\033[94mTesting timetable...")
response = client.post(reverse('timetable'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0})) response = client.post(reverse('timetable'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#EXAMS #EXAMS
print("\033[94mTesting exams...")
response = client.post(reverse('exams'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0})) response = client.post(reverse('exams'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#HOMEWORKS #HOMEWORKS
print("\033[94mTesting homeworks...")
response = client.post(reverse('homeworks'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0})) response = client.post(reverse('homeworks'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#ATTENDANCE #ATTENDANCE
print("\033[94mTesting attendance...")
response = client.post(reverse('attendance'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0})) response = client.post(reverse('attendance'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#NOTES #NOTES
print("\033[94mTesting notes...")
response = client.post(reverse('notes'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('notes'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#SCHOOL DATA #SCHOOL DATA
print("\033[94mTesting school data...")
response = client.post(reverse('school_data'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('school_data'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#DASHBOARD #DASHBOARD
print("\033[94mTesting dashboard...")
response = client.post(reverse('dashboard'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('dashboard'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#MOBILE ACCESS #MOBILE ACCESS
#REGISTERED DEVICES #REGISTERED DEVICES
print("\033[94mTesting registered devices...")
response = client.post(reverse('registered_devices'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('registered_devices'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#REGISTER DEVICE #REGISTER DEVICE
print("\033[94mTesting registering device...")
response = client.post(reverse('register_device'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('register_device'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#MESSAGES #MESSAGES
#RECEIVED MESSAGES #RECEIVED MESSAGES
print("\033[94mTesting received messages...")
messages_ids = [] messages_ids = []
response = client.post(reverse('received_messages'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('received_messages'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
messages_ids.append([response.json()['data']]) messages_ids.append([response.json()['data']])
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#SENT MESSAGES #SENT MESSAGES
print("\033[94mTesting sent messages...")
response = client.post(reverse('sent_messages'), content_type='appication/xml', data=json.dumps(cookies_data)) response = client.post(reverse('sent_messages'), content_type='appication/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
for id in response.json()['data']: for id in response.json()['data']:
messages_ids.append(id) messages_ids.append(id)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#DELETED MESSAGES #DELETED MESSAGES
print("\033[94mTesting deleted messages...")
response = client.post(reverse('deleted_messages'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('deleted_messages'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
messages_ids.append([response.json()['data']]) messages_ids.append([response.json()['data']])
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#GET RECIPIENTS #GET RECIPIENTS
print("\033[94mTesting getting recipients...")
response = client.post(reverse('recipients'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('recipients'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
recipients = response.json()['addressee']['data'] recipients = response.json()['addressee']['data']
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#STUDENT DATA #STUDENT DATA
print("\033[94mTesting student data...")
response = client.post(reverse('student_data'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('student_data'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#STATS #STATS
#PARTIAL #PARTIAL
print("\033[94mTesting partial grades stats...")
response = client.post(reverse('partial'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('partial'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#YEAR #YEAR
print("\033[94mTesting year grades stats...")
response = client.post(reverse('year'), content_type='application/xml', data=json.dumps(cookies_data)) response = client.post(reverse('year'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#SEND MESSAGE #SEND MESSAGE
print("\033[94mTesting sending message...")
for recipient in recipients: for recipient in recipients:
send_data = { send_data = {
'cookies_data': json.dumps(cookies_data), 'cookies_data': json.dumps(cookies_data),
@ -139,8 +251,13 @@ def get_data_test(client, cookies_data, assertEquals):
} }
response = client.post(reverse('send_message'), content_type='application/xml', data=json.dumps(send_data)) response = client.post(reverse('send_message'), content_type='application/xml', data=json.dumps(send_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
#GETTING MESSAGE CONTENT #GETTING MESSAGE CONTENT
print("\033[94mTesting getting content of message...")
for id in messages_ids: for id in messages_ids:
send_data = { send_data = {
'cookies_data': json.dumps(cookies_data), 'cookies_data': json.dumps(cookies_data),
@ -148,8 +265,17 @@ def get_data_test(client, cookies_data, assertEquals):
} }
response = client.post(reverse('message_content'), content_type='application/xml', data=json.dumps(send_data)) response = client.post(reverse('message_content'), content_type='application/xml', data=json.dumps(send_data))
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")
def log_out_test(client, assertEquals): def log_out_test(client, assertEquals):
#LOG OUT #LOG OUT
print("\033[94mTesting logging out...")
response = client.get(reverse('log_out'), content_type='application/xml') response = client.get(reverse('log_out'), content_type='application/xml')
assertEquals(response.status_code, 200) assertEquals(response.status_code, 200)
if response.status_code == 200:
print("\033[92mPassed!")
else:
print("\033[91mFailed!")