Skip to content

Commit

Permalink
Merge pull request #71 from crav12345/dev
Browse files Browse the repository at this point in the history
Iteration 2 final merge
  • Loading branch information
JarettSutula authored Nov 4, 2021
2 parents 1ba092f + adcb485 commit bd0ce20
Show file tree
Hide file tree
Showing 33 changed files with 1,325 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
.mutmut-cache

# Translations
*.mo
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# syntax=docker/dockerfile:1
FROM python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 GoatBoat

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.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 GoatBoat

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.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
run: clean install setup test mutatetest build
docker compose up

clean:
#cleans up cached files
@(rm -rf ./GoatBoat_Mentoring.egg-info)
@(rm -rf ./mentor/.mutmut-cache)
@(rm -rf ./mentor/__pycache__)
@(rm -rf ./mentor/GoatBoat_Mentoring.egg-info)
@(rm -rf ./mentor/mentor/__pycache__)
@(rm -rf ./mentor/mentor/GoatBoat_Mentoring.egg-info)

install:
#run setup.py to install modules
python setup.py install

#not sure if we need this if we have setup.py. Will ask Gildein.
setup: requirements.txt
pip install -r requirements.txt

#run tests
test:
python ./mentor/userform/tests.py
python ./mentor/formtests.py

#build dist
build:
python setup.py bdist

mutatetest:
-cd mentor && python -m mutmut run --paths-to-mutate=utils.py --runner "python -m unittest formtests.py"
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Goat Boat
<p align="center">
<img src="https://i.imgur.com/sUh3mN4.png" >
<p align="center">
<a href="https://www.python.org/" alt="python">
<img src="https://img.shields.io/badge/Made%20with-python-1f425f.svg" /></a>
<a href="https://choosealicense.com/licenses/mit/" alt="MIT">
<img src="https://img.shields.io/badge/license-MIT-orange" /></a>
</p>

# Mission Statement
To connect students with mentors to foster academic growth

Expand All @@ -9,19 +17,22 @@ To connect students with mentors to foster academic growth
4. Our team is committed to keeping up-to-date with changing educational circumstances even in a post-pandemic world.

# Branches
Branching on this project is inspired by the Gitflow method of branching. The main branch will be used for all major releases. Updates to main will come directly from the development branch as we do not plan on using release branches. New branches will be made off of dev for each feature that will be developed. Once a feature has been completed and merged into dev, the feature branch will be deleted.
Branching on this project is inspired by the Gitflow method of branching. The main branch will be used for all major releases. Updates to main will come directly from the development branch as we do not plan on using release branches. New branches will be made off of dev for each feature that will be developed. Once a feature has been completed and merged into dev, tested, and approved, the feature branch will be deleted.

Before merging a branch to dev or main, developers must create a pull request. Each pull request must be reviewed by and meet the standards of two team members other than the developer who authored the pull request.
Before merging a branch to dev or main, developers must create a pull request. Each pull request must be reviewed by and meet the standards of team members other than the developer who authored the pull request.

# Project Summary
Goat Boat is a web application that dynamically pairs students with tutors. When signing up for the service, both students and tutors will be asked to share a few, select details about themselves. Their responses allow our team to find ideal pairs that we guarantee will lead to a better academic experience for our users.

Users can select classes from their school course catalog to look for help with or to help others with. This way, users can decide to be a Mentor, a Mentee, or a mix of both, all through a simple form. From there, users can choose from a list of candidates that would help them with what they are looking for.

# Prerequisites
GoatBoat requires specific python packages for our team to help foster our users' academic growth. For now, these can be installed manually by running this command in the root directory:
> pip install -r requirements.txt
# Installation

# Proper Use

# Acknowledgements

# License Information
GoatBoat adheres to the MIT license. For more information, see [here](https://choosealicense.com/licenses/mit/).
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.9"

services:
web:
build: .
command: python ./mentor/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
Empty file added mentor/__init__.py
Empty file.
56 changes: 56 additions & 0 deletions mentor/formtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import unittest
from utils import create_day_array, collection_link, start_db

class TestFormCreation(unittest.TestCase):
"""Tests functions within create_user_form."""

def test_day_array_length(self):
"""Testing the create_day_array function. This is normally called
in the profile creation form to turn the user's time slots into
1-hour block objects for json storage.
"""
# Generate days with various scopes.
# day1 8am - 12pm, length should be 4, {8-9},{9-10},{10-11},{11-12}
test_day1 = create_day_array(8, 12)
self.assertEqual(len(test_day1), 4)

def test_day_array_empty(self):
"""create_day_array should return empty arrays if given incorrect
values.
"""
# Make sure days with -1 return empty array.
test_day1 = create_day_array(-1, 15)
test_day2 = create_day_array(10, -1)
test_day3 = create_day_array(-1, -1)
self.assertEqual(test_day1, [])
self.assertEqual(test_day2, [])
self.assertEqual(test_day3, [])

def test_day_array_ranges(self):
"""create_day_array needs to only return time frames between 8am and
10pm, indicated by integer values 8-22."""
with self.assertRaises(ValueError):
test_day1 = create_day_array(-5, 10)
with self.assertRaises(ValueError):
test_day2 = create_day_array(10, 23)

test_day3 = create_day_array(8, 22)

def test_day_array_input(self):
"""Testing the input of day_array."""
with self.assertRaises(TypeError):
test_day1 = create_day_array('string', 1)

def test_start_db(self):
"""Testing the connection to the database."""
result = start_db()
self.assertEqual(result.list_collection_names()[0], 'users')

def test_collection_link(self):
"""Testing the connection to a specific collection in db."""
my_db = start_db()
my_collection = collection_link(my_db, 'users')
self.assertGreater(my_collection.estimated_document_count(), 0)

if __name__ == '__main__':
unittest.main()
22 changes: 16 additions & 6 deletions mentor/mentor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -76,13 +77,15 @@

# Not using django database settings - everything handled on utils.py using pymongo

# DATABASES = {
# 'default': {
# 'ENGINE': 'pymongo',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

# log users out when the browser ends.
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -121,6 +124,13 @@
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/images/'
#
# STATICFILES_DIR = [
# os.path.join(BASE_DIR, 'static')
# ]

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
Expand Down
5 changes: 3 additions & 2 deletions mentor/test_view.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from utils import start_db
db_handle, users = start_db()
from utils import start_db, collection_link
db_handle= start_db()
users = collection_link(db_handle, 'users')

test_new = {
'firstName': 'testing',
Expand Down
62 changes: 62 additions & 0 deletions mentor/userform/dbtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from django.test import TestCase
import os
import unittest
import pymongo
from dotenv import load_dotenv
import certifi



# Create your tests here.

class TestDatabaseMethods(unittest.TestCase):

def test_dbconnect(self):
ca = certifi.where()

# load the .env file in local directories for DB access.
load_dotenv()
DB_USERNAME = os.getenv('DB_USERNAME')
DB_PASSWORD = os.getenv('DB_PASSWORD')
connection_string = "mongodb+srv://"+DB_USERNAME+":"+DB_PASSWORD+"@gb-mentoring-cluster.jhwgr.mongodb.net/?retryWrites=true&w=majority"

client = pymongo.MongoClient(connection_string, tlsCAfile = ca)
db_handle = client.get_database('gbmDB')

self.assertEqual(db_handle.list_collection_names()[0], 'users')

def test_dbcount(self):
ca = certifi.where()

# load the .env file in local directories for DB access.
load_dotenv()
DB_USERNAME = os.getenv('DB_USERNAME')
DB_PASSWORD = os.getenv('DB_PASSWORD')
connection_string = "mongodb+srv://"+DB_USERNAME+":"+DB_PASSWORD+"@gb-mentoring-cluster.jhwgr.mongodb.net/?retryWrites=true&w=majority"

client = pymongo.MongoClient(connection_string, tlsCAfile = ca)
db_handle = client.get_database('gbmDB')
db_collection = db_handle.users

self.assertNotEqual(db_collection.estimated_document_count(), 0)


def connect_db():
ca = certifi.where()

# load the .env file in local directories for DB access.
load_dotenv()
DB_USERNAME = os.getenv('DB_USERNAME')
DB_PASSWORD = os.getenv('DB_PASSWORD')
connection_string = "mongodb+srv://"+DB_USERNAME+":"+DB_PASSWORD+"@gb-mentoring-cluster.jhwgr.mongodb.net/?retryWrites=true&w=majority"

client = pymongo.MongoClient(connection_string, tlsCAfile = ca)
db_handle = client.get_database('gbmDB')

return db_handle



if __name__ == '__main__':
unittest.main()

Loading

0 comments on commit bd0ce20

Please sign in to comment.