Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
seripap committed Feb 6, 2020
2 parents 26f7a71 + 40e474f commit bcd2871
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"go.inferGopath": false
}
2 changes: 1 addition & 1 deletion citysummary/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestCitySummary(t *testing.T) {
assert.NotNil(t, property.Results.Location)

addressLookup := &firststreet.Lookup{
Address: "1327 Autumn Drive Fernandina Beach FL",
Address: "Fernandina Beach FL",
}

property, err = c.Lookup(addressLookup)
Expand Down
62 changes: 59 additions & 3 deletions marketvalueimpact/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@ func marketValueImpactPropertyHandler() http.HandlerFunc {
})
}

func TestMVILookup(t *testing.T) {
testutil.Once.Do(func() {
testutil.StartServer(marketValueImpactPropertyHandler())
func marketValueImpactCityHandler() http.HandlerFunc {
mviSample, err := ioutil.ReadFile(testutil.GetDirectoryPath() + "/fixtures/mvi-city.json")
if err != nil {
fmt.Println(err)
}

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// nolint
w.Write(mviSample)
})
}

func TestMVIPropertyLookup(t *testing.T) {
testutil.StartServer(marketValueImpactPropertyHandler())

testBackend.URL = testutil.ServerAddr
c := &Client{
B: testBackend,
Expand Down Expand Up @@ -74,3 +85,48 @@ func TestMVILookup(t *testing.T) {
assert.NotNil(t, mvi.Results)

}

func TestMVICityLookup(t *testing.T) {
testutil.StartServer(marketValueImpactCityHandler())

testBackend.URL = testutil.ServerAddr
c := &Client{
B: testBackend,
}

fsidLookup := &firststreet.Lookup{
FSID: "1222175",
}

mvi, err := c.Lookup(firststreet.CityLocationType, fsidLookup)
assert.Nil(t, err)
assert.NotNil(t, mvi)
assert.Equal(t, mvi.FSID, "1222175")
assert.NotNil(t, mvi.Results)

fsidLookupBad := &firststreet.Lookup{}
_, err = c.Lookup(firststreet.CityLocationType, fsidLookupBad)
assert.NotNil(t, err)

latLngLookup := &firststreet.Lookup{
Lat: -43.23,
Lng: -23.12,
}

mvi, err = c.Lookup(firststreet.CityLocationType, latLngLookup)
assert.Nil(t, err)
assert.NotNil(t, mvi)
assert.Equal(t, mvi.FSID, "1222175")
assert.NotNil(t, mvi.Results)

addressLookup := &firststreet.Lookup{
Address: "Fernandina Beach FL",
}

mvi, err = c.Lookup(firststreet.CityLocationType, addressLookup)
assert.Nil(t, err)
assert.NotNil(t, mvi)
assert.Equal(t, mvi.FSID, "1222175")
assert.NotNil(t, mvi.Results)

}
23 changes: 23 additions & 0 deletions marketvalueimpact/fixtures/mvi-city.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"FSID": "1222175",
"results": [{
"floodID": "kt",
"floodData": [{
"year": 2018,
"data": [{
"type": "loss_historic",
"unit": "dollars",
"value": -5993339.8641536
}]
},
{
"year": 2033,
"data": [{
"type": "loss_future",
"unit": "dollars",
"value": -6915392.15094647
}]
}
]
}]
}

0 comments on commit bcd2871

Please sign in to comment.