Skip to content

Commit 2e1e0b1

Browse files
Initial commit
1 parent d19f7bc commit 2e1e0b1

File tree

9 files changed

+331
-60
lines changed

9 files changed

+331
-60
lines changed

.csse6400/bin/clean_repository.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Ensure that students have not committed inappropriate files for a Git repository.
4+
5+
# The following files are not allowed in a Git repository.
6+
ILLEGAL_FILES=(.DS_Store .localized .DS_Store? ._* .Spotlight-V100 .Trashes Thumbs.db ehthumbs.db desktop.ini)
7+
ILLEGAL_FILES+=(*.pyc *.pyo *.exe *.dll *.so *.a *.o *.obj *.lib)
8+
ILLEGAL_FILES+=(__pycache__ *.class *.jar *.war *.rar)
9+
10+
failed=0
11+
for file in "${ILLEGAL_FILES[@]}"; do
12+
matches=$(git ls-files "${file}" 2>/dev/null)
13+
if [[ -n "${matches}" ]]; then
14+
echo "Found illegal file: ${matches}"
15+
failed=1
16+
fi
17+
done
18+
19+
if [ $failed -eq 1 ]; then
20+
echo "FAIL: Found illegal files in repository."
21+
echo "These files should not be committed to Git repositories - it is a good practice to add them to a .gitignore file."
22+
echo "Please remove these files and try again."
23+
exit 1
24+
fi
25+

.csse6400/bin/health.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#
3+
# Check that the health endpoint is returning 200
4+
5+
# Start flask app
6+
poetry install --no-root
7+
poetry run flask --app todo run -p 6400 &
8+
error=$?
9+
pid=$!
10+
if [[ $error -ne 0 ]]; then
11+
echo "Failed to start flask app"
12+
exit 1
13+
fi
14+
15+
# Wait for flask to start
16+
sleep 5
17+
18+
# Check that the health endpoint is returning 200
19+
curl -s -o /dev/null -w "%{http_code}" http://localhost:6400/api/v1/health | grep 200
20+
error=$?
21+
if [[ $error -ne 0 ]]; then
22+
echo "Failed to get 200 from health endpoint"
23+
exit 1
24+
fi
25+
26+
# Kill flask app
27+
kill $pid
28+

.csse6400/bin/unittest.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
#
3+
# Copy the tests directory and run the tests
4+
5+
cp -r .csse6400/tests .
6+
7+
poetry install --no-root
8+
poetry run python3 -m unittest discover -s tests
9+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
# Validate that the repository has the following structure:
4+
# -- README.md
5+
# -- pyproject.toml
6+
# -- todo
7+
# | -- __init__.py
8+
# | -- views
9+
# | -- routes.py
10+
11+
failed=0
12+
for file in README.md pyproject.toml; do
13+
if [ ! -f "$file" ]; then
14+
echo "FAIL: Missing $file"
15+
failed=1
16+
fi
17+
done
18+
19+
if [ ! -d todo ]; then
20+
echo "FAIL: Missing todo directory"
21+
failed=1
22+
fi
23+
24+
for file in todo/__init__.py todo/views/routes.py; do
25+
if [ ! -f "$file" ]; then
26+
echo "FAIL: Missing $file"
27+
failed=1
28+
fi
29+
done
30+
31+
if [ $failed -eq 1 ]; then
32+
echo "Repository structure is not valid. Please fix the errors above."
33+
exit 1
34+
fi
35+

.csse6400/tests/test_health.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
from todo import create_app
3+
4+
class TestHealth(unittest.TestCase):
5+
def setUp(self):
6+
self.client = create_app().test_client()
7+
8+
def test_health(self):
9+
response = self.client.get('/api/v1/health')
10+
self.assertEqual(response.status_code, 200)
11+
self.assertEqual(response.json, {'status': 'ok'})
12+
13+
if __name__ == '__main__':
14+
unittest.main()

.csse6400/tests/test_todo.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import unittest
2+
from todo import create_app
3+
4+
TEST_TODO = {
5+
"id": 1,
6+
"title": "Watch CSSE6400 Lecture",
7+
"description": "Watch the CSSE6400 lecture on ECHO360 for week 1",
8+
"completed": True,
9+
"deadline_at": "2026-02-27T18:00:00",
10+
"created_at": "2026-02-20T14:00:00",
11+
"updated_at": "2026-02-20T14:00:00"
12+
}
13+
14+
15+
class TestTodo(unittest.TestCase):
16+
def setUp(self):
17+
self.client = create_app().test_client()
18+
19+
def test_get_todo(self):
20+
response = self.client.get('/api/v1/todos')
21+
self.assertEqual(response.status_code, 200)
22+
self.assertEqual(response.json, [TEST_TODO])
23+
24+
def test_get_todo_by_id(self):
25+
response = self.client.get('/api/v1/todos/1')
26+
self.assertEqual(response.status_code, 200)
27+
self.assertEqual(response.json, TEST_TODO)
28+
29+
def test_post_todo(self):
30+
response = self.client.post('/api/v1/todos', json=TEST_TODO)
31+
self.assertEqual(response.status_code, 201)
32+
self.assertEqual(response.json, TEST_TODO)
33+
34+
def test_put_todo(self):
35+
response = self.client.put('/api/v1/todos/1', json=TEST_TODO)
36+
self.assertEqual(response.status_code, 200)
37+
self.assertEqual(response.json, TEST_TODO)
38+
39+
def test_delete_todo(self):
40+
response = self.client.delete('/api/v1/todos/1')
41+
self.assertEqual(response.status_code, 200)
42+
self.assertEqual(response.json, TEST_TODO)
43+

.github/workflows/classroom.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.gitignore

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
.idea/
161+
*.iml
162+
163+
# Ignore Apple junk files.
164+
**/.DS_Store
165+
**/._.DS_Store

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# CSSE6400 Week 1 Practical
2+
3+
Construction of a simple HTTP server in Python.
4+
5+
Please see the [instructions](https://csse6400.uqcloud.net/practicals/week01.pdf) for more details.
6+
7+
Update this README file with appropriate information about your project,
8+
including how to run it.
9+
10+
There are [resources](https://www.makeareadme.com) available to help you write a good README file.
11+
12+

0 commit comments

Comments
 (0)