<commit_before>package channel_product_test

import (
	"io/ioutil"
	"net/http"

	. "github.com/Shop2market/go-client/channel_product"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Channel product", func() {
	Context("parameters construction", func() {
		It("supports time ranges", func() {
			server := ghttp.NewServer()
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/shops/1/publishers/5/ads", "start=20150105&end=20150505"),
					ghttp.RespondWith(http.StatusOK, "[]"),
				),
			)
			Endpoint = server.URL()

			FindAds(&AdQuery{ProductsQuery: &ProductsQuery{ShopId: 1, PublisherId: 5}, StartTimeId: "20150105", EndTimeId: "20150505"})
		})

		It("supports only_with_stats", func() {
			server := ghttp.NewServer()
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/shops/1/publishers/5/ads", "start=20150105&end=20150505&only_with_stats=true"),
					ghttp.RespondWith(http.StatusOK, "[]"),
				),
			)
			Endpoint = server.URL()

			FindAds(&AdQuery{ProductsQuery: &ProductsQuery{ShopId: 1, PublisherId: 5}, StartTimeId: "20150105", EndTimeId: "20150505", OnlyWithStats: true})
		})
	})

	It("deserializes response", func() {
		content, err := ioutil.ReadFile("fixtures/ads_response.json")
		Expect(err).NotTo(HaveOccurred())

		server := ghttp.NewServer()
		server.AppendHandlers(
			ghttp.RespondWith(http.StatusOK, string(content)),
		)

		Endpoint = server.URL()
		ads, _ := FindAds(&AdQuery{ProductsQuery: &ProductsQuery{ShopId: 1, PublisherId: 5}})
		Expect(ads).To((HaveLen(2)))
		timestr := "2015-11-04 14:16:58.52 +0000 UTC"
		Expect(ads[0].QuarantinedAt.String()).To(Equal(timestr))
	})
})<commit_msg>PD-2834: add tests to stock_status and products_in_stock<commit_after>package channel_product_test

import (
	"io/ioutil"
	"net/http"

	. "github.com/Shop2market/go-client/channel_product"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Channel product", func() {
	Context("parameters construction", func() {
		It("supports time ranges", func() {
			server := ghttp.NewServer()
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/shops/1/publishers/5/ads", "start=20150105&end=20150505"),
					ghttp.RespondWith(http.StatusOK, "[]"),
				),
			)
			Endpoint = server.URL()

			FindAds(&AdQuery{ProductsQuery: &ProductsQuery{ShopId: 1, PublisherId: 5}, StartTimeId: "20150105", EndTimeId: "20150505"})
		})

		It("supports only_with_stats", func() {
			server := ghttp.NewServer()
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/shops/1/publishers/5/ads", "start=20150105&end=20150505&only_with_stats=true"),
					ghttp.RespondWith(http.StatusOK, "[]"),
				),
			)
			Endpoint = server.URL()

			FindAds(&AdQuery{ProductsQuery: &ProductsQuery{ShopId: 1, PublisherId: 5}, StartTimeId: "20150105", EndTimeId: "20150505", OnlyWithStats: true})
		})
	})

	It("deserializes response", func() {
		content, err := ioutil.ReadFile("fixtures/ads_response.json")
		Expect(err).NotTo(HaveOccurred())

		server := ghttp.NewServer()
		server.AppendHandlers(
			ghttp.RespondWith(http.StatusOK, string(content)),
		)

		Endpoint = server.URL()
		ads, _ := FindAds(&AdQuery{ProductsQuery: &ProductsQuery{ShopId: 1, PublisherId: 5}})
		Expect(ads).To((HaveLen(2)))
		timestr := "2015-11-04 14:16:58.52 +0000 UTC"
		Expect(ads[0].QuarantinedAt.String()).To(Equal(timestr))
		Expect(ads[0].StockStatus).To(Equal("yes"))
		Expect(ads[0].ProductsInStock).To(Equal(0))
	})
})
{'fraction_non_alphanumeric': 0.1728395061728395, 'fraction_numerical': 0.0551440329218107, 'mean_word_length': 4.899676375404531, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7118723', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1337, 'n_words': 188}