Commit 5329658d authored by Leonard Marschke's avatar Leonard Marschke

sync with main repo

parent b9f44590
Pipeline #8477 failed with stages
in 30 seconds
MIT License
Copyright (c) 2019 Leonard Marschke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -52,14 +52,14 @@ with database_holder.database.transaction():
We recommend you to use an IDE like PyCharm for developing this piece of software.
If you are not familiar with IDEs in general you should use this project as a starting point.
Trust us, you will have many (Python) projects where a nice IDE is a real gamechanger.
Trust us, you will have many (Python) projects where a nice IDE is a real game-changer.
## Development setup
You have to set the correct PythonPath when executing the tests to the base directory of this project.
The PythonPath is the base path for the Python interpreter, which is used for resolving imports.
When you are executing the `main.py` file from the project root, you most likely will not have to modify your PythonPath.
In order to execute this project, you have to have a recent Python Interpreter (we recommend Python 3.6, 3.5 should work as well, Python 2 is not working) with pip (normally installed along).
In order to execute this project, you have to have a recent Python Interpreter (we recommend at least Python 3.7, 3.6 should work as well, Python 2 is not working) with pip (normally installed along with Python).
Also you have to install all the project requirements stated in `requirements.txt`.
You can do so by executing `pip3 install -r requirements.txt --no-cache-dir` in your project folder.
......@@ -108,32 +108,36 @@ If you are using PyCharm you can use the built in test environment as well.
Just add a new run config `Python tests` -> `unittest` pointing to the test directory of this project.
As a pattern please provide `Test*.py` because we do not use the standard pattern for our tests.
We provide you a set of test, which we use (not exclusively) to grade your hand-in. So make sure these tests are running successfully.
## Writing tests
We do not require you but encourage you to write tests for your application. You can do so by adding methods beginning with `test_` in `tests/TestBlueprintV1.py`.
We do not require you but encourage you to write additional tests for your application. You can do so by adding methods beginning with `test_` in `tests/TestBlueprintV1.py`.
We are using the `flask_testing` [framework](https://github.com/jarus/flask-testing) to execute our tests - just in case you want a reference.
### Linter
If you are really ambitious you can run `pylint` with our own flavour.
Because you are so ambitious you can pick up the command right from our `.gitlab-ci.yml`, which we are using normally for all our projects.
To grade this assignment we use `pylint` with [this](https://sre18.pages.rechenknecht.net/misc/pylintrc) config.
If you are really ambitious you can also run `pylint` with our own flavour, but please make sure our requirements are met fully.
To test your project against our `pylint` rules, you can pick up the command right from our `.gitlab-ci.yml` (`python-style` stage).
### GitLab
Just in case you want to use the automated test and linter feature you have to upload the code simply to a GitLab instance with a configured worker on it.
Just in case you want to use the automated test and linter feature you have to upload the code simply to a GitLab instance with a configured CI worker on it.
## Docker
The following section is just for your information. You do not have to use Docker or understand it at all (at this moment).
**Note:** The following section is just for your information. You do not have to use Docker or understand it at all (at this moment).
We provide a simple Docker file for you, which should have all features you need.
If you think it would be better to use another Docker base you can surely do it as long as you ensure that you expose your web server on port `8080`.
You can build the Docker container by executing `docker build .` (you should define `--tag=someTag` to use the image later on).
If you are new to Docker, please check out [this](https://docs.docker.com/get-started/) little guide which explains the core concepts (you only need part 1 and 2).
If you are new to Docker, please check out [this](https://docs.docker.com/get-started/) little guide which explains the core concepts (you only need part one and two).
Also you should get information about how to build a Docker container.
Please make sure you can build the Docker container before handing in your solution.
We will grade the software in the container and because you want to get some credits for this assignment you should make sure that we can build the container right off.
## Ok, I really do not know what I am supposed to do
If you have any questions left or found a bug in our stub code, please mail us at `www-coding@lists.myhpi.de`.
If you have any questions left or found a bug in our stub code, please mail us at `www@lists.myhpi.de`.
We will be happy to help you.
......@@ -11,7 +11,9 @@ import re
from lxml import html
import requests
from flask import Blueprint, request, Response
from flask import Blueprint, request
from flask_common.util import proxy
from app import database_holder
......@@ -109,8 +111,8 @@ def get_answers():
def update_image_storage():
"""This operation should clear DB if run multiple times on the same DB
8 Points: 3 for xpath (1 each), 1 for correct resource GET, 2 for correct DB entry handling,
2 for correct regex, 2 for Transaction explanation
8 Points: 3 for xpath (1 each), 1 for correct resource GET, 2 for correct DB handling,
1 for correct regex, 1 for Transaction explanation
-0.5 for small mistakes (return value...)
:return: json if successful or not
......
......@@ -4,7 +4,7 @@ info:
version: "1.0.0"
title: "Flask Training API"
contact:
email: "www-coding@lists.myhpi.de"
email: "www@lists.myhpi.de"
servers:
- url: "https://someserver/v1"
......
......@@ -39,6 +39,45 @@ class V1Test(TestCase):
self.assertEqual('image/jpeg', image_bitmap_response.content_type)
self.assertGreater(len(image_bitmap_response.data), 100)
def test_invalid_images_limit_text(self):
image_list_response = self.client.get('/images?limit=bla')
self.assert400(image_list_response)
def test_invalid_images_limit_negative(self):
image_list_response = self.client.get('/images?limit=-123')
self.assert400(image_list_response)
def test_invalid_images_limit_large(self):
image_list_response = self.client.get('/images?limit=501')
self.assert400(image_list_response)
def test_invalid_images_offset_text(self):
image_list_response = self.client.get('/images?offset=fds')
self.assert400(image_list_response)
def test_invalid_images_offset_negative(self):
image_list_response = self.client.get('/images?offset=-3')
self.assert400(image_list_response)
def test_images_offset_large(self):
image_list_response = self.client.get('/images?offset=10000')
self.assert200(image_list_response)
self.assertEqual(len(image_list_response.json['images']), 0)
def test_unknown_image_metadata(self):
image_bitmap_response = self.client.get('/images/9999')
self.assert404(image_bitmap_response)
self.assertGreater(len(image_bitmap_response.json['message']), 8)
def test_unknown_image_bitmap(self):
image_bitmap_response = self.client.get('/images/9999/bitmap')
self.assert404(image_bitmap_response)
def test_get_answers(self):
answers_response = self.client.get('/answers')
self.assert200(answers_response)
def test_get_task_list(self):
task_response = self.client.get('/tasks')
self.assert200(task_response)
Markdown is supported
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