Skip to content

Commit

Permalink
test: fixed broken tests related to Yahooo API contract change
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed May 29, 2023
1 parent e6f263b commit 2618b45
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 108 deletions.
2 changes: 1 addition & 1 deletion internal/quote/quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func mockResponseCurrencyEURUSD() {
"quoteType": "CURRENCY",
"quoteSourceName": "Delayed Quote",
"currency": "EUR",
"regularMarketPrice": 0.8891,
"regularMarketPrice": {"raw": 0.8891,"fmt": "0.8891"},
"sourceInterval": 15,
"exchangeDataDelayedBy": 0,
"exchange": "CCY",
Expand Down
76 changes: 54 additions & 22 deletions internal/quote/yahoo/quote_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,58 +44,58 @@ var _ = Describe("Quote", func() {
"type": "string"
},
"regularMarketChange": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketChangePercent": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketPrice": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketTime": {
"type": "integer"
"$ref": "#/definitions/fieldInteger"
},
"regularMarketPreviousClose": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketOpen": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketDayRange": {
"type": "string"
"$ref": "#/definitions/fieldString"
},
"regularMarketDayHigh": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketDayLow": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"regularMarketVolume": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"postMarketChange": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"postMarketChangePercent": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"postMarketPrice": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"preMarketChange": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"preMarketChangePercent": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"preMarketPrice": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"fiftyTwoWeekHigh": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"fiftyTwoWeekLow": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"symbol": {
"type": "string"
Expand All @@ -107,16 +107,48 @@ var _ = Describe("Quote", func() {
"type": "number"
},
"marketCap": {
"type": "number"
"$ref": "#/definitions/fieldNumber"
},
"quoteType": {
"type": "string"
}
}
},
"fieldNumber": {
"properties": {
"raw": {
"type": "number"
},
"fmt": {
"type": "string"
}
}
},
"fieldInteger": {
"properties": {
"raw": {
"type": "integer"
},
"fmt": {
"type": "string"
}
}
},
"fieldString": {
"properties": {
"raw": {
"type": "string"
},
"fmt": {
"type": "string"
}
}
}
},
"required": ["quoteResponse"]
}`
"required": [
"quoteResponse"
]
}`

client := yahooClient.New()

Expand Down Expand Up @@ -146,7 +178,7 @@ var _ = Describe("Quote", func() {
}

Expect(result.Valid()).To(Equal(true))
Expect(resp.Status).To(Equal("200 OK"))
Expect(resp.StatusCode()).To(Equal(200))
})
})
})
110 changes: 55 additions & 55 deletions internal/quote/yahoo/yahoo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "REGULAR",
"shortName": "Cloudflare, Inc.",
"preMarketChange": 1.0399933,
"preMarketChangePercent": 1.2238094,
"preMarketPrice": 86.03,
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketPrice": 84.98,
"regularMarketPreviousClose": 84.00,
"regularMarketOpen": 85.22,
"regularMarketDayHigh": 90.00,
"regularMarketDayLow": 80.00,
"postMarketChange": 1.37627,
"postMarketChangePercent": 1.35735,
"postMarketPrice": 86.56,
"preMarketChange": { "raw": 1.0399933, "fmt": "1.0399933"},
"preMarketChangePercent": { "raw": 1.2238094, "fmt": "1.2238094"},
"preMarketPrice": { "raw": 86.03, "fmt": "86.03"},
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"regularMarketPreviousClose": { "raw": 84.00, "fmt": "84.00"},
"regularMarketOpen": { "raw": 85.22, "fmt": "85.22"},
"regularMarketDayHigh": { "raw": 90.00, "fmt": "90.00"},
"regularMarketDayLow": { "raw": 80.00, "fmt": "80.00"},
"postMarketChange": { "raw": 1.37627, "fmt": "1.37627"},
"postMarketChangePercent": { "raw": 1.35735, "fmt": "1.35735"},
"postMarketPrice": { "raw": 86.56, "fmt": "86.56"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -77,12 +77,12 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "PRE",
"shortName": "Cloudflare, Inc.",
"preMarketChange": 1.0399933,
"preMarketChangePercent": 1.2238094,
"preMarketPrice": 86.03,
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketPrice": 84.98,
"preMarketChange": { "raw": 1.0399933, "fmt": "1.0399933"},
"preMarketChangePercent": { "raw": 1.2238094, "fmt": "1.2238094"},
"preMarketPrice": { "raw": 86.03, "fmt": "86.03"},
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -120,9 +120,9 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "PRE",
"shortName": "Cloudflare, Inc.",
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketPrice": 84.98,
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -162,12 +162,12 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "POST",
"shortName": "Cloudflare, Inc.",
"postMarketChange": 1.0399933,
"postMarketChangePercent": 1.2238094,
"postMarketPrice": 86.02,
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketPrice": 84.98,
"postMarketChange": { "raw": 1.0399933, "fmt": "1.0399933"},
"postMarketChangePercent": { "raw": 1.2238094, "fmt": "1.2238094"},
"postMarketPrice": { "raw": 86.02, "fmt": "86.02"},
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -205,11 +205,11 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "POST",
"shortName": "Cloudflare, Inc.",
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketTime": 1608832801,
"regularMarketPrice": 84.98,
"regularMarketPreviousClose": 81.9,
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketTime": { "raw": 1623777601, "fmt": "4:00PM EDT"},
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"regularMarketPreviousClose": { "raw": 81.9, "fmt": "81.9"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -245,11 +245,11 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "CLOSED",
"shortName": "Cloudflare, Inc.",
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketTime": 1608832801,
"regularMarketPrice": 84.98,
"regularMarketPreviousClose": 81.9,
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketTime": { "raw": 1623777601, "fmt": "4:00PM EDT" },
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"regularMarketPreviousClose": { "raw": 81.9, "fmt": "81.9"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -287,14 +287,14 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "CLOSED",
"shortName": "Cloudflare, Inc.",
"postMarketChange": 1.0399933,
"postMarketChangePercent": 1.2238094,
"postMarketPrice": 86.02,
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketTime": 1608832801,
"regularMarketPrice": 84.98,
"regularMarketPreviousClose": 81.9,
"postMarketChange": { "raw": 1.0399933, "fmt": "1.0399933"},
"postMarketChangePercent": { "raw": 1.2238094, "fmt": "1.2238094"},
"postMarketPrice": { "raw": 86.02, "fmt": "86.02"},
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketTime": { "raw": 1623777601, "fmt": "4:00PM EDT" },
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"regularMarketPreviousClose": { "raw": 81.9, "fmt": "81.9"},
"symbol": "NET"
}
],
Expand Down Expand Up @@ -334,12 +334,12 @@ var _ = Describe("Yahoo Quote", func() {
{
"marketState": "PRE",
"shortName": "Cloudflare, Inc.",
"preMarketChange": 1.0399933,
"preMarketChangePercent": 1.2238094,
"preMarketPrice": 86.03,
"regularMarketChange": 3.0800018,
"regularMarketChangePercent": 3.7606857,
"regularMarketPrice": 84.98,
"preMarketChange": { "raw": 1.0399933, "fmt": "1.0399933"},
"preMarketChangePercent": { "raw": 1.2238094, "fmt": "1.2238094"},
"preMarketPrice": { "raw": 86.03, "fmt": "86.03"},
"regularMarketChange": { "raw": 3.0800018, "fmt": "3.0800018"},
"regularMarketChangePercent": { "raw": 3.7606857, "fmt": "3.7606857"},
"regularMarketPrice": { "raw": 84.98, "fmt": "84.98"},
"symbol": "BTC-USD",
"quoteType": "CRYPTOCURRENCY"
}
Expand Down Expand Up @@ -417,7 +417,7 @@ var _ = Describe("Yahoo Quote", func() {
"quoteResponse": {
"result": [
{
"regularMarketPrice": 1.2,
"regularMarketPrice": { "raw": 1.2, "fmt": "1.2"},
"currency": "EUR",
"symbol": "EURUSD=X"
}
Expand Down Expand Up @@ -445,7 +445,7 @@ var _ = Describe("Yahoo Quote", func() {
"quoteResponse": {
"result": [
{
"regularMarketPrice": 160.0,
"regularMarketPrice": { "raw": 160.0, "fmt": "160.0"},
"symbol": "VOW3.DE"
}
],
Expand All @@ -472,7 +472,7 @@ var _ = Describe("Yahoo Quote", func() {
"quoteResponse": {
"result": [
{
"regularMarketPrice": 160.0,
"regularMarketPrice": { "raw": 160.0, "fmt": "160.0"},
"currency": "EUR",
"symbol": "VOW3.DE"
}
Expand Down
Loading

0 comments on commit 2618b45

Please sign in to comment.