Skip to content

Commit

Permalink
Merge pull request #229 from COS301-SE-2024/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Dominique-Da-Silva authored Jul 5, 2024
2 parents 59e5657 + 0de42e1 commit bf6e8f2
Show file tree
Hide file tree
Showing 66 changed files with 1,520 additions and 994 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

# dependencies
node_modules
.pnp
.pnp.js
.yarn/install-state.gz

# virtual environments
mycity-venv/
Expand All @@ -16,5 +19,34 @@ __pycache__/
.env.development
.env.production

# testing
coverage

# next.js
.next/
out/

# production
build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# next.js transpiler
.swc

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# jest & playwright test results
/test-results
3 changes: 3 additions & 0 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from chalicelib.issues.issues_routes import issues_routes
from chalicelib.tickets.tickets_routes import tickets_blueprint
from chalicelib.searching.searching_routes import searching_blueprint
from chalicelib.municipalities.municipalities_routes import municipalities_blueprint

app = Chalice(app_name="mycity")
cors_config = CORSConfig(
Expand All @@ -20,6 +21,8 @@

app.register_blueprint(searching_blueprint, "Search", "/search")

app.register_blueprint(municipalities_blueprint, "Municipality", "/municipality")


@app.route("/", cors=True)
def index():
Expand Down
39 changes: 39 additions & 0 deletions backend/chalicelib/municipalities/municipalities_controllers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import boto3
from botocore.exceptions import ClientError
from chalice import BadRequestError, Response
import json

dynamodb = boto3.resource("dynamodb")
municipalities_table = dynamodb.Table("municipalities")


def format_response(status_code, body):
return Response(
body=json.dumps(body),
status_code=status_code,
headers={
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
"Access-Control-Allow-Headers": "Authorization,Content-Type,X-Amz-Date,X-Amz-Security-Token,X-Api-Key",
},
)


def get_all_municipalities():
try:
response = municipalities_table.scan()
municipalities = response.get("Items", [])

# Note that only the name of the municipality is being fetched
municipalities_list = [
{
"municipality_id": municipality["municipality_id"],
}
for municipality in municipalities
]

return format_response(200, municipalities_list)

except ClientError as e:
error_message = e.response["Error"]["Message"]
return {"Status": "FAILED", "Error": error_message}
13 changes: 13 additions & 0 deletions backend/chalicelib/municipalities/municipalities_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from chalice import Blueprint, BadRequestError, Response
from chalicelib.municipalities.municipalities_controllers import (
get_all_municipalities,
)

municipalities_blueprint = Blueprint(__name__)


@municipalities_blueprint.route("/municipalities-list", methods=["GET"], cors=True)
# Note that only the name of the municipality is being fetched
def get_all_municipalities_list():
municipalities_list = get_all_municipalities()
return municipalities_list
1 change: 0 additions & 1 deletion backend/chalicelib/profiles/__init__.py

This file was deleted.

106 changes: 0 additions & 106 deletions backend/chalicelib/profiles/profiles_controllers.py

This file was deleted.

28 changes: 0 additions & 28 deletions backend/chalicelib/profiles/profiles_routes.py

This file was deleted.

8 changes: 8 additions & 0 deletions backend/chalicelib/tickets/tickets_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ def get_in_my_municipality(tickets_data):
"municipality_id",
]
for field in required_fields:
if tickets_data == None:
error_response = {
"Error": {
"Code": "Nothing",
"Message": f"No data has been sent",
}
}
raise ClientError(error_response, "NothingSent")
if field not in tickets_data:
error_response = {
"Error": {
Expand Down
15 changes: 9 additions & 6 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ bcrypt==4.1.3
black==24.4.2
blessed==1.20.0
blinker==1.8.2
boto3==1.34.117
botocore==1.34.111
boto3==1.34.132
botocore==1.34.132
certifi==2024.6.2
chalice==1.31.1
chalice==1.31.2
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
Expand All @@ -21,18 +21,21 @@ jinxed==1.2.1
jmespath==1.0.1
MarkupSafe==2.1.5
mypy-extensions==1.0.0
packaging==24.0
packaging==24.1
pathspec==0.12.1
platformdirs==4.2.2
pur==7.3.2
pyasn1==0.6.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-editor==1.0.4
PyYAML==6.0.1
readchar==4.1.0
requests==2.32.3
s3transfer==0.10.1
s3transfer==0.10.2
six==1.16.0
urllib3==2.2.1
tomli==2.0.1
typing_extensions==4.12.2
urllib3==2.2.2
wcwidth==0.2.13
Werkzeug==3.0.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import CitizenLogin from "@/components/Login/CitizenLogin";
import { fireEvent, render, screen } from "@testing-library/react";

describe("Dashboard", () => {


/* it("renders an email input", () => {
render(<CitizenLogin />);
const emailInput = screen.getByLabelText("Email");
expect(emailInput).toBeInTheDocument();
expect(emailInput).toHaveAttribute("type", "email");
}); */

it("renders an email input", () => {
render(<CitizenLogin />);
// Use getByPlaceholderText if the placeholder is unique
const emailInput = screen.getByPlaceholderText("[email protected]");

expect(emailInput).toBeInTheDocument();
expect(emailInput).toHaveAttribute("type", "email");
});

// it("renders a password input", () => {
// render(<CitizenLogin />);
// const passwordInput = screen.getByLabelText("Password");

// expect(passwordInput).toBeInTheDocument();
// expect(passwordInput).toHaveAttribute("type", "password");
// });


// it("renders a forgot password link", () => {
// render(<CitizenLogin />);
// const forgotPasswordLink = screen.getByText("Forgot password?");

// expect(forgotPasswordLink).toBeInTheDocument();
// });

// it("renders a Login button", () => {
// render(<CitizenLogin />);
// const submitButton = screen.getByTestId("submit-btn")

// expect(submitButton).toBeInTheDocument();
// });


// test("handler function is called after clicking submit button", () => {
// render(<CitizenLogin />);
// const mockFunction = jest.fn();
// const loginForm = screen.getByTestId("citizen-login-form");
// loginForm.addEventListener("submit", mockFunction);

// fireEvent.submit(loginForm)
// expect(mockFunction).toHaveBeenCalledTimes(1);
// });

});
Loading

0 comments on commit bf6e8f2

Please sign in to comment.