Functional Weave
Code in Python

property.rent-review@1.0.0

vectors.json

6,640 bytes · view raw

[
 {
  "name": "index up 10%, no collar or cap: £55,000",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1320,
   null,
   null,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5500000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5500000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 1000,
   "appliedBy": "index"
  }
 },
 {
  "name": "index up 10% with a 4% cap: £52,000",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1320,
   200,
   400,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5200000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5500000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 1000,
   "appliedBy": "cap"
  }
 },
 {
  "name": "index up 3% between a 2% collar and 4% cap",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1236,
   200,
   400,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5150000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5150000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 300,
   "appliedBy": "index"
  }
 },
 {
  "name": "index up 1% under a 2% collar: the collar sets it",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1212,
   200,
   400,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5100000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5050000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 100,
   "appliedBy": "collar"
  }
 },
 {
  "name": "index exactly on the cap: the index sets it",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1250,
   1300,
   null,
   400,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5200000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5200000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 400,
   "appliedBy": "index"
  }
 },
 {
  "name": "index falls 5%, upward-only: rent stays at £50,000",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1320,
   1254,
   null,
   null,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5000000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 4750000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": -500,
   "appliedBy": "upward-only"
  }
 },
 {
  "name": "index falls 5%, not upward-only: rent falls to £47,500",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1320,
   1254,
   null,
   null,
   false
  ],
  "expect": {
   "newRent": {
    "minor": 4750000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 4750000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": -500,
   "appliedBy": "index"
  }
 },
 {
  "name": "index falls 5% with a 1% collar and no upward-only: the collar still lifts it",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1320,
   1254,
   100,
   null,
   false
  ],
  "expect": {
   "newRent": {
    "minor": 5050000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 4750000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": -500,
   "appliedBy": "collar"
  }
 },
 {
  "name": "a negative collar limits a fall to 2%",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1320,
   1254,
   -200,
   null,
   false
  ],
  "expect": {
   "newRent": {
    "minor": 4900000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 4750000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": -500,
   "appliedBy": "collar"
  }
 },
 {
  "name": "a flat index, upward-only: unchanged, by the index",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1200,
   null,
   null,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5000000,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5000000,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 0,
   "appliedBy": "index"
  }
 },
 {
  "name": "applying the index, not a rounded percentage: 1200 to 1277 is £53,208.33, not £53,210.00",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1277,
   null,
   null,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5320833,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5320833,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 642,
   "appliedBy": "index"
  }
 },
 {
  "name": "the rent is rounded half-up once",
  "args": [
   {
    "minor": 1234567,
    "currency": "GBP"
   },
   1000,
   1033,
   null,
   null,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 1275308,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 1275308,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 330,
   "appliedBy": "index"
  }
 },
 {
  "name": "a tiny movement: 8 basis points shown, exact rent used",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1201,
   null,
   null,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 5004167,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 5004167,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 8,
   "appliedBy": "index"
  }
 },
 {
  "name": "a peppercorn stays a peppercorn",
  "args": [
   {
    "minor": 0,
    "currency": "GBP"
   },
   1200,
   1320,
   200,
   400,
   true
  ],
  "expect": {
   "newRent": {
    "minor": 0,
    "currency": "GBP"
   },
   "indexRent": {
    "minor": 0,
    "currency": "GBP"
   },
   "indexChangeBasisPoints": 1000,
   "appliedBy": "cap"
  }
 },
 {
  "name": "a collar above the cap is refused",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1320,
   500,
   400,
   true
  ],
  "expectError": "collar 500 is above cap 400"
 },
 {
  "name": "a zero base index is refused",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   0,
   1320,
   null,
   null,
   true
  ],
  "expectError": "baseIndex must be an integer from 1 to"
 },
 {
  "name": "a fractional index is refused",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   128.4,
   133.9,
   null,
   null,
   true
  ],
  "expectError": "baseIndex must be an integer from 1 to"
 },
 {
  "name": "a negative rent is refused",
  "args": [
   {
    "minor": -1,
    "currency": "GBP"
   },
   1200,
   1320,
   null,
   null,
   true
  ],
  "expectError": "passingRent must be between 0 and"
 },
 {
  "name": "a cap of -100% is refused",
  "args": [
   {
    "minor": 5000000,
    "currency": "GBP"
   },
   1200,
   1320,
   null,
   -10000,
   true
  ],
  "expectError": "capBasisPoints must be an integer from -9999 to 100000"
 }
]