API/Unit Tests Flashcards

1
Q

Servers

A
  • ## local or cloud based
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

server load handling

A
  1. get a bigger server
  2. get more servers
    2a. get a load balancer to distribute
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

load balancer process distribution methods

A
  1. random
  2. series
  3. fewest processes
    also redistributes load on a server fail
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

databases

A
  • many servers can communicate with it
  • can be partitioned
  • can be replicated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

database replication strats

A
  1. single primary: original has read and write capabilities, sends updates to its replicas
  2. multi primary: both original and replica has read/write capabilities and update one another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

REST API

A

Representational state transfer application programming interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

REST requests

A
  • URLS identify resources
  • HTTP methods to perform operations
  • HTTP headers to specify data format for resources that are returned
  • HTTP status codes for success/failure (200 OK)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

HTTP Methods

A
  • create: POST/PUT
  • retrieve: GET
  • update: PUT/PATCH
  • delete: DELETE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

HTTP Headers

A

2 kinds: content-type and accept

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

GET examples

A

GET /users
GET /users/2
GET /users/pages/1 (GET /users?page=1)
GET /users/gender/female (GET /users?gender=female&userid=2) * GET /users/age/18 (GET /users?age=18)
GET /users/2/name
GET /users/2/pets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

POST example

A

POST /users HTTP/1.1
Host: the-website.com
Accept: application/json
Content-Type: application/xml
Content-Length: 49

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

PUT example

A

PUT /users/3 HTTP/1.1
Host: the-website.com
Content-Type: application/xml
Content-Length: 52

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

DELETE example

A

DELETE /users/2 HTTP/1.1
Host: the-website.com

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

PATCH example

A

PATCH /users/1 HTTP/1.1
Host: the-website.com
Content-Type: application/xml
Content-Length: 37

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

test-driven-development

A
  • software development planning with verification of results as the focus; no coding until we know how it will be tested
  • other methods include behavior-driven-development: code until functionality is observed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

test case vs suite

A
  • test case: single input with an expected output
  • test suite: collection of test cases
17
Q

unit testing

A
  • each js file is a module
  • each function within a module is a unit
  • pre and post conditions are important here
18
Q

integrated testing

A

test if all modules of your code interact together as intended

19
Q

system testing

A

~Dev white box tests~
1. function test; functional reqs are met
2. quality test; non-functional reqs
~Consumer black box tests~
3. acceptance test; customer verifies all reqs
4. installation test; testing in user env (the platform)

20
Q

good tests

A
  • boundary/edge cases; min/max parameters for input values
  • error/empty cases: 0, -1, an empty array, etc.
  • test behaviors/functions in combination, not just as units
21
Q

Node’s assert module

assert.equal(actual, expected)
-value
assert.strictEqual(actual, expected)
-value + data type

A
  • simple set of assertion tests to test invariants
  • provides limited feedback on test fails
  • 11 methods
22
Q

Use Mocha for automated testing

A

at the minimum, use console.log();