From b5b6e641778c39a2f4e2362e69d7326e2133d289 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 15 Apr 2020 17:41:53 -0600 Subject: [PATCH] Added testing and ci build, refactored filter class, refactored project structure --- .gitignore | 1 + .travis.yml | 6 + Dockerfile | 4 +- README.md | 20 ++- app/filter.py | 179 ++++++++++---------- app/routes.py | 37 ++-- opensearch.py => config/opensearch.py | 6 +- requirements.txt => config/requirements.txt | 1 + run | 33 ++++ run.sh | 17 -- server.py | 1 - test/__init__.py | 0 test/conftest.py | 8 + test/test_results.py | 54 ++++++ test/test_routes.py | 30 ++++ 15 files changed, 269 insertions(+), 128 deletions(-) create mode 100644 .travis.yml rename opensearch.py => config/opensearch.py (73%) rename requirements.txt => config/requirements.txt (94%) create mode 100755 run delete mode 100755 run.sh delete mode 100644 server.py create mode 100644 test/__init__.py create mode 100644 test/conftest.py create mode 100644 test/test_results.py create mode 100644 test/test_routes.py diff --git a/.gitignore b/.gitignore index 469cf3d..1c70601 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__/ *.pem *.xml config.json +test/static diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b9200fe --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: python +python: 3.6 +install: + - pip install -r config/requirements.txt +script: + - ./run test diff --git a/Dockerfile b/Dockerfile index 2007e76..dc0e92c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ FROM python:3 WORKDIR /usr/src/app COPY . . -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r config/requirements.txt -CMD ["./run.sh"] +CMD ["./run"] diff --git a/README.md b/README.md index db6340e..df38f69 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,26 @@ heroku open Now you're done! This series of commands can take a while, but once you run it once, you shouldn't have to run it again. The final command, `heroku open` will launch a tab in your web browser, where you can test out Shoogle and even [set it as your primary search engine](https://github.com/benbusby/shoogle#set-shoogle-as-your-primary-search-engine). #### B) Using your own server, or alternative container deployment -There are other methods for deploying docker containers that are well outlined in [this article](https://rollout.io/blog/the-shortlist-of-docker-hosting/), but there are too many to describe set up for each here. Generally it should be about the same amount of effort as the Heroku deployment. +There are other methods for deploying docker containers that are well outlined in [this article](https://rollout.io/blog/the-shortlist-of-docker-hosting/), but there are too many to describe set up for each here. Generally it should be about the same amount of effort as the Heroku deployment. Depending on your preferences, you can also deploy the app yourself on your own infrastructure. This route would require a few extra steps: - A server (I personally recommend [Digital Ocean](https://www.digitalocean.com/pricing/) or [Linode](https://www.linode.com/pricing/), their cheapest tiers will work fine) - Your own URL (I suppose this is optional, but recommended) - SSL certificates (free through [Let's Encrypt](https://letsencrypt.org/getting-started/)) - A bit more experience or willingness to work through issues - + +## Setup (Local Only) +If you want to test the app out on your own machine first, you can build it with the following instructions: + +```bash +git clone https://github.com/benbusby/shoogle.git +cd shoogle +python3 -m venv venv +source venv/bin/activate +pip install -r config/requirements.txt +./run +``` + ## Usage Same as most search engines, with the exception of filtering by time range. @@ -44,7 +56,7 @@ To filter by a range of time, append ":past