-
Notifications
You must be signed in to change notification settings - Fork 2
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 #229 from COS301-SE-2024/development
Development
- Loading branch information
Showing
66 changed files
with
1,520 additions
and
994 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
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
39 changes: 39 additions & 0 deletions
39
backend/chalicelib/municipalities/municipalities_controllers.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
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
13
backend/chalicelib/municipalities/municipalities_routes.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
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
frontend/__tests__/components/Dashboard/FaultCardContainer.test.tsx
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,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); | ||
// }); | ||
|
||
}); |
Oops, something went wrong.