Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Fang-Pen Lin fangpenlin

🚀
View GitHub Profile
View open_sesame.py
import os
import subprocess
from flask import Flask
from flask import request
from flask import abort
app = Flask(__name__)
API_KEY = os.environ["API_KEY"]
View keybase.md

Keybase proof

I hereby claim:

  • I am fangpenlin on github.
  • I am fangpenlin (https://keybase.io/fangpenlin) on keybase.
  • I have a public key whose fingerprint is A576 16E6 2A49 9B51 2EDA 662E 0FC8 D700 8588 874B

To claim this, I am signing this object:

View keybase.md

Keybase proof

I hereby claim:

  • I am fangpenlin on github.
  • I am fangpenlin (https://keybase.io/fangpenlin) on keybase.
  • I have a public key whose fingerprint is 1B7C ED10 1EB7 AC0A 7FFD C71D 8CB0 4455 CD16 EB73

To claim this, I am signing this object:

View keybase.md

Keybase proof

I hereby claim:

  • I am victorlin on github.
  • I am fangpenlin (https://keybase.io/fangpenlin) on keybase.
  • I have a public key whose fingerprint is 1B7C ED10 1EB7 AC0A 7FFD C71D 8CB0 4455 CD16 EB73

To claim this, I am signing this object:

View envoy-embassy-article-json-resp.json
[
{
"id": "01",
"name": "john"
},
{
"id": "02",
"name": "tom"
}
]
View envoy-embassy-article-test-case-example.rb
import XCTest
import Embassy
import EnvoyAmbassador
class MyUITests: UITestBase {
func testUserList() {
router[DefaultRouter.fetchUsersPath] = DelayResponse(JSONResponse(handler: { _ in
return [
["id": "01", "name": "John"],
View envoy-embassy-article-podfile.rb
target 'MyProjectUITests' do
pod 'Embassy', '~> 1.0'
pod 'EnvoyAmbassador', '~> 0.0.1-alpha-1'
end
View envoy-embassy-article-ui-test-base.swift
import Foundation
import XCTest
import Embassy
import EnvoyAmbassador
class UITestBase: XCTestCase {
let port = 8080
var router: Router!
var eventLoop: EventLoopType!
View envoy-embassy-article-default-router.swift
class DefaultRouter: Router {
static let fetchUsersPath = "/api/v2/users"
override init() {
super.init()
self[DefaultRouter.fetchUsersPath] = DelayResponse(JSONResponse(handler: ({ environ -> AnyObject in
return [
["id": "01", "name": "john"],
["id": "02", "name": "tom"]
]
})))
View envoy-embassy-article-set-env-vars-for-mocking.swift
app = XCUIApplication()
app.launchEnvironment["MOCK_API_CLIENT"] = "true"
app.launchEnvironment["MOCK_GET_USER_ERROR_CODE"] = "402"
app.launch()