Giter Club home page Giter Club logo

ust-sas-api-test's Introduction

UST School Administration Systems API Test

Node Version

v15.4.0

Unit Tests

Tests are run using jest and supertest

npm test

Test suites

  • validation tests
    1. Should accept full entries
    2. Should not accept missing entries
    3. Should not accept empty fields
  • endpoint tests
    1. GET /workload should return 200
    2. POST /register should return 204 with full body information
    3. POST /register should 400 if body is missing items
    4. POST /register should return 400 if body has empty fields

Initialising the API server

  • Install dependencies
npm install
  • Start server
npm start

This will start a docker container, and migrate the database from /database/DDL.sql


API Docuemntation

All reqeusts should be made to this base URL:

http://localhost:3000/api

Test

/healthcheck

method: GET

expected response: 200 OK


Registering A New Lesson With Teachers, Students, Classes, and Subject

/register

method: POST

required payload:

  1. teacher
    • name
    • email
  2. students (array of)
    • name
    • email
  3. subject
    • name
    • subjectCode
  4. class
    • name
    • classCode

If any of the items already exist as their unique identifier, but name fields are different, it will be updated to that provided in the request.

All fields must be provided.

Example body:
{
  "students": [
    {
      "name": "Student A",
      "email": "[email protected]"
    },
    {
      "name": "Student B",
      "email": "[email protected]"
    }],
   "class": {
      "classCode": "P1-1",
      "name": "P1 AA"
   },
   "subject": {
      "subjectCode": SCI,
      "name": "Science"
   },
      "teacher": {
      "name": Teacher 1,
      "email": "[email protected]"
   }
}

expected response: 204 NO CONTENT


Retrieving Overall Workload

/reports/workload
  • method: GET
  • expected response: 200
    {
      "Teacher 1": [
        {
          "subjectCode": "ENG",
          "subjectName": "English",
          "numberOfClasses": 1,
        },        
        {
          "subjectCode": "MATH",
          "subjectName": "Mathematics",
          "numberOfClasses": 3,
        },
      ],
      "Teacher 2": [
        {
          "subjectCode": "ENG",
          "subjectName": "English",
          "numberOfClasses": 2,
        },
      ],
    }

ust-sas-api-test's People

Contributors

ryhuz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.