当前位置: 首页>>代码示例>>Golang>>正文


Golang gaetest.ResetFixtureFromFile函数代码示例

本文整理汇总了Golang中lib/wcg/gae/gaetest.ResetFixtureFromFile函数的典型用法代码示例。如果您正苦于以下问题:Golang ResetFixtureFromFile函数的具体用法?Golang ResetFixtureFromFile怎么用?Golang ResetFixtureFromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ResetFixtureFromFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Test_API_Task_List

func Test_API_Task_List(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_Task_List.json", nil), "fixture")

	now, _ := wcg.ParseDateTime("2016-01-10T00:00:00Z")

	lib.TemporarySetNow(now, func() {
		req := ts.GET("/api/admin/tasks/")
		res := req.RouteTo(instance.Routes())
		assert.HTTPStatus(200, res)

		var got entities.Pagination
		assert.JSONResponse(&got, res)
		assert.EqInt(0, got.Length())
	})

	now, _ = wcg.ParseDateTime("2016-01-09T00:00:00Z")

	lib.TemporarySetNow(now, func() {
		req := ts.GET("/api/admin/tasks/")
		res := req.RouteTo(instance.Routes())
		assert.HTTPStatus(200, res)

		var got entities.Pagination
		assert.JSONResponse(&got, res)
		assert.EqInt(1, got.Length())
	})
}
开发者ID:speedland,项目名称:service,代码行数:28,代码来源:api_tasks_test.go

示例2: Test_API_Tasks_Crawlers_Ameblo_Posts

func Test_API_Tasks_Crawlers_Ameblo_Posts(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_Tasks_Crawlers_Ameblo_Posts.json", nil, "hplink"), "fixture")

	p := entities.AmebloPost.Query().MustExecute(ts.GET("/").Request)
	postList := p.Data.([]hplink.AmebloPost)
	assert.EqInt(1, len(postList))

	httptest.StartMockServer(func(mock *httptest.MockServer) {
		mock.Routes().GET("/morningmusume-9ki/post.html", middleware.ServeFile("./fixtures/mocks/ameblo.jp//morningmusume-9ki/post.html"))
		crawler.MockExternalResource(map[string]string{
			"http://ameblo.jp/morningmusume-9ki/entry-12201946654.html": fmt.Sprintf("%s//morningmusume-9ki/post.html", mock.BaseURL()),
		}, func() {
			runner := testhelper.NewAsyncTaskTestRunner(t, instance.Routes(), ts)
			runner.OnMonitor(func(testreq *httptest.TestRequest, f func()) {
				testhelper.TemporaryAllow(testreq, "hplink.admin", f)
			})
			runner.OnTrigger(func(testreq *httptest.TestRequest, f func()) {
				testhelper.TemporaryAllow(testreq, "hplink.admin", f)
			})
			runner.Run("/api/hplink/tasks/crawlers/ameblo/posts/", url.Values{})

			p := entities.AmebloPost.Query().MustExecute(ts.GET("/").Request)
			postList := p.Data.([]hplink.AmebloPost)
			assert.EqInt(1, len(postList))
			assert.EqStr("ノーメイク☆譜久村聖", postList[0].Title)
			assert.EqStr("譜久村聖", postList[0].Theme)
			assert.EqStr("morningmusume.mizuki_fukumura", postList[0].MemberKey)

			// It also creates a URL cache
			assert.EqInt(1, entities.URLCache.Query().MustCount(ts.GET("/").Request))
		})
	})
}
开发者ID:speedland,项目名称:service,代码行数:34,代码来源:api_tasks_test.go

示例3: Test_API_Config_Get_Default

func Test_API_Config_Get_Default(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_Config_Get.json", nil), "fixture")
	testUser := httptest.NewTestUser().SetID("facebook:6789")
	dummy := ts.GET("/")

	configs.TemporarySetConfig(dummy.Request,
		"facebook_page_id", "12345",
		func() {
			messenger.TemporaryOptIn(dummy.Request,
				"12345", testUser.ID(),
				func() {
					var notif pt.MessengerNotification
					req := ts.GET("/api/intern/pt/configs/facebook%3A6789/messenger.json")
					req.Request.User = testUser
					helper.TemporaryAllow(req, "family", func() {
						res := req.RouteTo(instance.Routes())
						assert.HTTPStatus(200, res)
						assert.JSONResponse(&notif, res)
						assert.EqStr("facebook:6789", notif.UserID, "MessengerNotification.UserID")
						assert.OK(!notif.Summary, "MessengerNotification.Summary")
						assert.OK(!notif.OnStart, "MessengerNotification.OnStart")
						assert.OK(!notif.OnEnd, "MessengerNotification.OnEnd")
					})
				},
			)
		},
	)
}
开发者ID:speedland,项目名称:service,代码行数:29,代码来源:api_configs_test.go

示例4: Test_API_Tasks_Crawlers_Ameblo_EntryLists

func Test_API_Tasks_Crawlers_Ameblo_EntryLists(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_Tasks_Crawlers_Ameblo_EntryLists.json", nil, "hplink"), "fixture")

	httptest.StartMockServer(func(mock *httptest.MockServer) {
		mock.Routes().GET("/morningmusume-9ki/entrylist.html", middleware.ServeFile("./fixtures/mocks/ameblo.jp//morningmusume-9ki/entrylist.html"))
		crawler.MockExternalResource(map[string]string{
			"http://ameblo.jp/morningmusume-9ki/entrylist.html": fmt.Sprintf("%s//morningmusume-9ki/entrylist.html", mock.BaseURL()),
		}, func() {
			runner := testhelper.NewAsyncTaskTestRunner(t, instance.Routes(), ts)
			runner.OnMonitor(func(testreq *httptest.TestRequest, f func()) {
				testhelper.TemporaryAllow(testreq, "hplink.admin", f)
			})
			runner.OnTrigger(func(testreq *httptest.TestRequest, f func()) {
				testhelper.TemporaryAllow(testreq, "hplink.admin", f)
			})
			runner.Run("/api/hplink/tasks/crawlers/ameblo/entrylists/", url.Values{})

			p := entities.AmebloPost.Query().Order("-PostAt").MustExecute(ts.GET("/").Request)
			postList := p.Data.([]hplink.AmebloPost)
			assert.EqInt(20, len(postList))
			assert.EqStr("ノーメイク☆譜久村聖", postList[0].Title)
			assert.EqStr("", postList[0].Theme)
			assert.EqStr("morningmusume.mizuki_fukumura", postList[0].MemberKey)
			assert.EqStr("http://ameblo.jp/morningmusume-9ki/", postList[0].SettingsURL)

			p = entities.CrawlerSettings.Query().Filter("URL=", "http://ameblo.jp/morningmusume-9ki/").MustExecute(ts.GET("/").Request)
			assert.EqInt(1, p.Length())
			settings := p.Head().(*hplink.CrawlerSettings)
			assert.EqInt(int(hplink.CrawlerStatusSuccess), int(settings.Status))
		})
	})
}
开发者ID:speedland,项目名称:service,代码行数:33,代码来源:api_tasks_test.go

示例5: Test_API_IEPGRecord_OptInOut_Excluded

func Test_API_IEPGRecord_OptInOut_Excluded(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_IEPGRecord_OptInOut.json", nil, "intern.pt"), "fixture")

	req := ts.PUTForm(fmt.Sprintf("/api/intern/pt/iepg/records/%s/opt-in/", "excluded"), url.Values{
		"opt_in": []string{"1"},
	})
	helper.TemporaryAllow(req, "family", func() {
		var got pt.IEPG
		res := req.RouteTo(instance.Routes())
		assert.HTTPStatus(200, res)
		assert.JSONResponse(&got, res)
		assert.OK(got.OptIn, "OptIn")
		assert.OK(!got.OptOut, "OptOut")
	})

	req = ts.PUTForm(fmt.Sprintf("/api/intern/pt/iepg/records/%s/opt-in/", "excluded"), url.Values{
		"opt_in": []string{"0"},
	})
	helper.TemporaryAllow(req, "family", func() {
		var got pt.IEPG
		res := req.RouteTo(instance.Routes())
		assert.HTTPStatus(200, res)
		assert.JSONResponse(&got, res)
		assert.OK(!got.OptIn, "OptIn")
		assert.OK(!got.OptOut, "OptOut")
	})
}
开发者ID:speedland,项目名称:service,代码行数:28,代码来源:api_iepg_records_test.go

示例6: Test_API_SystemStats_Query

func Test_API_SystemStats_Query(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_SystemStats_Query.json", nil, "intern.home"), "fixture")

	app := NewApp()
	req := ts.GET("/api/intern/home/stats/servers/dummy/system/")
	res := req.RouteTo(app.Routes())
	assert.HTTPStatus(200, res)
	var got []home.SystemStats
	assert.JSONResponse(&got, res)
	assert.EqInt(0, len(got), string(res.Body))

	req = ts.GET("/api/intern/home/stats/servers/dummy/system/?until=2014-12-01T11:00:00Z")
	res = req.RouteTo(app.Routes())
	assert.HTTPStatus(200, res)
	assert.JSONResponse(&got, res)
	assert.EqInt(2, len(got), string(res.Body))

	tempnow, _ := wcg.ParseDateTime("2014-12-01T11:00:00Z")
	lib.TemporarySetNow(tempnow, func() {
		req := ts.GET("/api/intern/home/stats/servers/dummy/system/")
		res := req.RouteTo(app.Routes())
		assert.HTTPStatus(200, res)
		var got []home.SystemStats
		assert.JSONResponse(&got, res)
		assert.EqInt(2, len(got), string(res.Body))
	})

}
开发者ID:speedland,项目名称:service,代码行数:29,代码来源:api_stats_test.go

示例7: Test_ByHeader

func Test_ByHeader(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_HeaderAuth.json", nil), "fixture")

	router := wcg.NewRouter()
	handler := wcg.AnonymousHandler(func(res *wcg.Response, req *wcg.Request) {
		res.WriteString(req.User.ID())
	})
	byHeader(router, func() {
		router.GET("/api/foo", handler)
		router.GET("/cron/foo", handler)
	})
	req := ts.GET("/api/foo")
	assert.EqStr("-", string(req.RouteTo(router).Body), "Guest")

	req = ts.GET("/api/foo")
	req.AddHeader(request.APITokenHeader, "2e489f08-3be9-4d28-af86-b14841b2181a")
	assert.EqStr("api:2e489f08-3be9-4d28-af86-b14841b2181a", string(req.RouteTo(router).Body), "APITokenUser")

	req = ts.GET("/api/foo")
	req.AddHeader(request.APITokenHeader, "invalidtoken")
	assert.EqStr("-", string(req.RouteTo(router).Body), "Guest")

	req = ts.GET("/api/foo")
	req.AddHeader(request.TaskQueueHeader, "true")
	assert.EqStr(fmt.Sprintf("api:%s", request.APITokenForTask), string(req.RouteTo(router).Body), "Guest")

	req = ts.GET("/cron/foo")
	req.AddHeader(request.CronHeader, "true")
	assert.EqStr(fmt.Sprintf("api:%s", request.APITokenForCron), string(req.RouteTo(router).Body), "CronUser")

}
开发者ID:speedland,项目名称:service,代码行数:32,代码来源:header_test.go

示例8: Test_API_CronStatsCleanup

func Test_API_CronStatsCleanup(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_SystemStats_Query.json", nil, "intern.home"), "fixture")

	sk, _ := Server.Get().Key("dummy").MustOne(ts.GET("/").Request)
	c := SystemStats.Query().Ancestor(sk).MustCount(ts.GET("/").Request)
	assert.EqInt(2, c)

	tempnow, _ := wcg.ParseDateTime("2014-12-01T11:00:00Z")
	lib.TemporarySetNow(tempnow, func() {
		app := NewApp()
		req := ts.GET("/cron/intern/home/stats/cleanup/")
		res := req.RouteTo(app.Routes())
		assert.HTTPStatus(200, res)

		// confirm nothing deleted
		c = SystemStats.Query().Ancestor(sk).MustCount(ts.GET("/").Request)
		assert.EqInt(2, c)
	})

	app := NewApp()
	req := ts.GET("/cron/intern/home/stats/cleanup/")
	res := req.RouteTo(app.Routes())
	assert.HTTPStatus(200, res)

	// everything deleted since it's old
	c = SystemStats.Query().Ancestor(sk).MustCount(ts.GET("/").Request)
	assert.EqInt(0, c)
}
开发者ID:speedland,项目名称:service,代码行数:29,代码来源:cron_stats_test.go

示例9: Test_API_Artist_Member_Get

func Test_API_Artist_Member_Get(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_Artist_Member_Get.json", nil, "hplink"), "fixture")
	req := ts.GET("/api/hplink/c-ute/members/maimi_yajima.json")
	res := req.RouteTo(instance.Routes())
	var got map[string]interface{}
	assert.HTTPStatus(200, res)
	assert.JSONResponse(&got, res)
	assert.EqStr("c-ute.maimi_yajima", got["key"].(string))
}
开发者ID:speedland,项目名称:service,代码行数:10,代码来源:api_members_test.go

示例10: Test_API_IEPGExclusion_List

func Test_API_IEPGExclusion_List(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_IEPGExclusion_List.json", nil, "intern.pt"))
	req := ts.GET("/api/intern/pt/iepg/exclusions/")
	res := req.RouteTo(instance.Routes())
	assert.HTTPStatus(200, res)

	var got []pt.IEPGExclusion
	assert.JSONResponse(&got, res)
	assert.EqInt(2, len(got), string(res.Body))
}
开发者ID:speedland,项目名称:service,代码行数:11,代码来源:api_iepg_exclusions_test.go

示例11: Test_API_Artist_Members_All

func Test_API_Artist_Members_All(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_Artist_Members_All.json", nil, "hplink"), "fixture")
	req := ts.GET("/api/hplink/c-ute/members/")
	res := req.RouteTo(instance.Routes())
	var got []*hplink.Member
	assert.HTTPStatus(200, res)
	assert.JSONResponse(&got, res)
	assert.EqInt(1, len(got))
	assert.EqStr("c-ute.maimi_yajima", got[0].Key)
}
开发者ID:speedland,项目名称:service,代码行数:11,代码来源:api_members_test.go

示例12: Test_API_CrawlerSettings_Delete

func Test_API_CrawlerSettings_Delete(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_CrawlerSettings_Delete.json", nil, "hplink"), "fixture")
	req := ts.DELETE("/api/hplink/crawlersettings/http%3A%2F%2Fameblo.jp%2Fc-ute-official%2F.json")
	testhelper.TemporaryAllow(req, "hplink.admin", func() {
		res := req.RouteTo(instance.Routes())
		assert.HTTPStatus(200, res)
		_, settings := entities.CrawlerSettings.Get().Key("http://ameblo.jp/c-ute-official/").MustOne(ts.GET("/").Request)
		assert.Nil(settings)
	})
}
开发者ID:speedland,项目名称:service,代码行数:11,代码来源:api_crawler_settings_test.go

示例13: Test_API_CrawlerSettings_All

func Test_API_CrawlerSettings_All(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_CrawlerSettings_All.json", nil, "hplink"), "fixture")
	req := ts.GET("/api/hplink/crawlersettings/ameblo/")
	res := req.RouteTo(instance.Routes())
	var got []*hplink.CrawlerSettings
	assert.HTTPStatus(200, res)
	assert.JSONResponse(&got, res)
	assert.EqInt(1, len(got))
	assert.EqStr("http://ameblo.jp/c-ute-official/", got[0].URL)
}
开发者ID:speedland,项目名称:service,代码行数:11,代码来源:api_crawler_settings_test.go

示例14: Test_API_APIToken_List

func Test_API_APIToken_List(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_APIToken_List.json", nil), "fixture")

	req := ts.GET("/api/admin/api_tokens/")
	res := req.RouteTo(instance.Routes())
	assert.HTTPStatus(200, res)

	var got []models.APIToken
	assert.JSONResponse(&got, res)
	assert.EqInt(1, len(got), "ListAPIToken length")
}
开发者ID:speedland,项目名称:service,代码行数:12,代码来源:api_api_tokens_test.go

示例15: Test_API_OAuth2ClientSettings_List

func Test_API_OAuth2ClientSettings_List(t *testing.T) {
	assert := gaetest.NewAssert(t)
	assert.Nil(gaetest.ResetFixtureFromFile(ts.Context, "./fixtures/Test_API_OAuth2ClientSettings_List.json", nil), "fixture")

	req := ts.GET("/api/admin/oauth2/clients/")
	res := req.RouteTo(instance.Routes())
	assert.HTTPStatus(200, res)

	var got []models.OAuth2ClientSettings
	assert.JSONResponse(&got, res)
	assert.EqInt(1, len(got), "OAuth2ClientSettings length")
}
开发者ID:speedland,项目名称:service,代码行数:12,代码来源:api_oauth2_test.go


注:本文中的lib/wcg/gae/gaetest.ResetFixtureFromFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。