-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from crav12345/dev
Iteration 2 final merge
- Loading branch information
Showing
33 changed files
with
1,325 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ coverage.xml | |
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
.mutmut-cache | ||
|
||
# Translations | ||
*.mo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
Oops, something went wrong.