super-test 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGE.txt +9 -0
- data/README.txt +13 -0
- data/bin/idb +19 -0
- data/bin/ii +113 -0
- data/bin/istart_mock +36 -0
- data/bin/istop_mock +16 -0
- data/bin/kk +181 -0
- data/bin/rubyatp +42 -0
- data/bin/start_mock +36 -0
- data/bin/stop_mock +16 -0
- data/bin/xgo +45 -0
- data/conf/conf.rb +11 -0
- data/conf/db03.yml +31 -0
- data/conf/db13.yml +37 -0
- data/conf/db19.yml +33 -0
- data/conf/online.yml +32 -0
- data/conf/super_test.yml +40 -0
- data/conf/system.yml +26 -0
- data/conf/sz00.yml +31 -0
- data/conf/sz06.yml +34 -0
- data/conf/wise00.yml +11 -0
- data/data/case.house +0 -0
- data/data/char.house +0 -0
- data/data/images/Bluehills.jpg +0 -0
- data/data/images/Sunset.jpg +0 -0
- data/data/images/Waterlilies.jpg +0 -0
- data/data/images/Winter.jpg +0 -0
- data/data/query.house +18595 -0
- data/data/user.house +8 -0
- data/lib/action/module/check_action.rb +58 -0
- data/lib/action/module/cnnt_action.rb +161 -0
- data/lib/action/module/datacenter_action.rb +48 -0
- data/lib/action/module/http_pack_helper.rb +163 -0
- data/lib/action/module/httpserver_action.rb +297 -0
- data/lib/action/module/inc.rb +21 -0
- data/lib/action/module/mcpack_action.rb +57 -0
- data/lib/action/module/sql_action.rb +84 -0
- data/lib/action/module/ssh_action.rb +37 -0
- data/lib/action/system/user_action.rb +180 -0
- data/lib/common/appium_helper.rb +217 -0
- data/lib/common/atp_helper.rb +74 -0
- data/lib/common/atp_report.rb +344 -0
- data/lib/common/data_house.rb +405 -0
- data/lib/common/data_model.rb +87 -0
- data/lib/common/http/assert_helper.rb +343 -0
- data/lib/common/http/fix_hpricot.rb +118 -0
- data/lib/common/http/html_helper.rb +362 -0
- data/lib/common/http/http_helper.rb +469 -0
- data/lib/common/http/multipart.rb +81 -0
- data/lib/common/isandbox_helper.rb +195 -0
- data/lib/common/json_helper.rb +43 -0
- data/lib/common/mock_helper.rb +168 -0
- data/lib/common/mtop_helper.rb +141 -0
- data/lib/common/myconf_helper.rb +49 -0
- data/lib/common/mylog_helper.rb +77 -0
- data/lib/common/pairwise.rb +121 -0
- data/lib/common/query_house.rb +89 -0
- data/lib/common/report_helper.rb +97 -0
- data/lib/common/robot_helper.rb +85 -0
- data/lib/common/socket/check.rb +325 -0
- data/lib/common/socket/conf_modifier.rb +149 -0
- data/lib/common/socket/context.rb +55 -0
- data/lib/common/socket/data.rb +392 -0
- data/lib/common/socket/data_helper.rb +41 -0
- data/lib/common/socket/env.rb +317 -0
- data/lib/common/socket/inc.rb +24 -0
- data/lib/common/socket/log.rb +213 -0
- data/lib/common/socket/log4s.rb +58 -0
- data/lib/common/socket/log_helper.rb +332 -0
- data/lib/common/socket/my_sql.rb +77 -0
- data/lib/common/socket/net.rb +74 -0
- data/lib/common/socket/network.rb +115 -0
- data/lib/common/socket/rlib/conf_modifier.rb +130 -0
- data/lib/common/socket/rlib/data_helper.rb +33 -0
- data/lib/common/socket/rlib/log_helper.rb +303 -0
- data/lib/common/socket/rlib/process_helper.rb +91 -0
- data/lib/common/socket/stub.rb +276 -0
- data/lib/common/socket/util.rb +266 -0
- data/lib/patterns/inc.rb +10 -0
- data/lib/patterns/mc_base_pattern.rb +474 -0
- data/lib/patterns/some_pattern.rb +145 -0
- data/lib/super_test.rb +114 -0
- data/log/super_test.log +0 -0
- data/log/super_test.log.wf +0 -0
- data/test/cover_me.rb +6 -0
- data/tool/jenny +0 -0
- data/tool/mcsend/mcsend2 +0 -0
- data/tool/mcsend/mcsend2_shead +0 -0
- data/tool/mcserver/conf/mcserver.conf +77 -0
- data/tool/mcserver/conf/mcserverauthip +17 -0
- data/tool/mcserver/mcserver +0 -0
- data/tool/mcserver/mcserver_trans +0 -0
- data/tool/mysql +0 -0
- data/tool/net/mcsend/mcsend +0 -0
- data/tool/net/mcsend/mcsend_trans +0 -0
- data/tool/net/mcsend/nshead.data +7 -0
- data/tool/net/mcsend/res_nshead.data +7 -0
- data/tool/net/my_client/my_client +0 -0
- data/tool/net/tsclient/client.tcl +205 -0
- data/tool/others/kk +190 -0
- data/tool/others/rubyatp +42 -0
- data/tool/others/supertest_install.sh +34 -0
- data/tool/trip/idb +0 -0
- data/tool/ts-agent/nshead.bft +12 -0
- data/tool/ts-agent/server.conf +10 -0
- data/tool/ts-agent/server.tcl +376 -0
- metadata +275 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
# Takes a hash of string and file parameters and returns a string of text
|
2
|
+
# formatted to be sent as a multipart form post.
|
3
|
+
#
|
4
|
+
# Author:: Cody Brimhall <mailto:cbrimhall@ucdavis.edu>
|
5
|
+
# Created:: 22 Feb 2008
|
6
|
+
# coding: utf-8
|
7
|
+
|
8
|
+
require 'mime/types'
|
9
|
+
require 'cgi'
|
10
|
+
|
11
|
+
|
12
|
+
module Multipart
|
13
|
+
VERSION = "1.0.0" unless const_defined?(:VERSION)
|
14
|
+
|
15
|
+
# Formats a given hash as a multipart form post
|
16
|
+
# If a hash value responds to :string or :read messages, then it is
|
17
|
+
# interpreted as a file and processed accordingly; otherwise, it is assumed
|
18
|
+
# to be a string
|
19
|
+
class Post
|
20
|
+
# We have to pretend like we're a web browser...
|
21
|
+
USERAGENT = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/523.10.6 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6" unless const_defined?(:USERAGENT)
|
22
|
+
#BOUNDARY = "0123456789ABLEWASIEREISAWELBA9876543210" unless const_defined?(:BOUNDARY)
|
23
|
+
BOUNDARY = "--------------01234HELLOSPACE56789" unless const_defined?(:BOUNDARY)
|
24
|
+
CONTENT_TYPE = "multipart/form-data; boundary=#{ BOUNDARY }" unless const_defined?(:CONTENT_TYPE)
|
25
|
+
HEADER = { "Content-Type" => CONTENT_TYPE, "User-Agent" => USERAGENT } unless const_defined?(:HEADER)
|
26
|
+
|
27
|
+
def self.prepare_query(params)
|
28
|
+
fp = []
|
29
|
+
|
30
|
+
params.each do |k, v|
|
31
|
+
# Are we trying to make a file parameter?
|
32
|
+
if v.respond_to?(:path) and v.respond_to?(:read) then
|
33
|
+
fp.push(FileParam.new(k, v.path, v.read))
|
34
|
+
# We must be trying to make a regular parameter
|
35
|
+
else
|
36
|
+
fp.push(StringParam.new(k, v))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Assemble the request body using the special multipart format
|
41
|
+
query = fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--\r\n"
|
42
|
+
return query, HEADER
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# Formats a basic string key/value pair for inclusion with a multipart post
|
49
|
+
class StringParam
|
50
|
+
attr_accessor :k, :v
|
51
|
+
|
52
|
+
def initialize(k, v)
|
53
|
+
@k = k
|
54
|
+
@v = v
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_multipart
|
58
|
+
return "Content-Disposition: form-data; name=\"#{k}\"\r\n\r\n#{v.to_s.force_encoding('ISO-8859-1')}\r\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Formats the contents of a file or string for inclusion with a multipart
|
63
|
+
# form post
|
64
|
+
class FileParam
|
65
|
+
attr_accessor :k, :filename, :content
|
66
|
+
|
67
|
+
def initialize(k, filename, content)
|
68
|
+
@k = k
|
69
|
+
@filename = filename
|
70
|
+
@content = content
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_multipart
|
74
|
+
# If we can tell the possible mime-type from the filename, use the
|
75
|
+
# first in the list; otherwise, use "application/octet-stream"
|
76
|
+
mime_type = MIME::Types.type_for(filename)[0] || MIME::Types["application/octet-stream"][0]
|
77
|
+
return "Content-Disposition: form-data; name=\"#{k}\"; filename=\"#{ filename }\"\r\n" +
|
78
|
+
"Content-Type: #{ mime_type.simplified }\r\n\r\n#{ content }\r\n"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: yzm
|
5
|
+
# Date:: 2016-03-01 19:05:44 +0800
|
6
|
+
###########################################
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# 封装访问ios设备沙盒文件的核心模块
|
11
|
+
module ISandBoxHelper
|
12
|
+
# include ConfigHelper
|
13
|
+
|
14
|
+
# === 功能:
|
15
|
+
# 向非越狱iphone推送一段内容
|
16
|
+
#
|
17
|
+
# === 参数解释:
|
18
|
+
# filename: 只是存储文件名,不带路径,目前mock路径是约定的
|
19
|
+
# data: 推送内容,一般是string,其他可以直接写入文件的写可以
|
20
|
+
#
|
21
|
+
# === Example:
|
22
|
+
# Example #1:
|
23
|
+
#
|
24
|
+
def ipush_data(path, data, filename='')
|
25
|
+
mount
|
26
|
+
begin
|
27
|
+
root_folder = $isandbox_operator.tmp_folder_name + path
|
28
|
+
exec_cmd("mkdir #{root_folder}") unless File.directory? root_folder
|
29
|
+
filename = root_folder + '/' + filename.to_s.split('/')[-1]
|
30
|
+
# 去除可能的 //
|
31
|
+
filename.sub(/\/\//, '/')
|
32
|
+
File.open(filename, "w+") do |file|
|
33
|
+
file.puts data
|
34
|
+
end
|
35
|
+
rescue
|
36
|
+
p "error:#{$!} at:#{$@}"
|
37
|
+
ensure
|
38
|
+
umount
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# === 功能:
|
43
|
+
# 向非越狱iphone推送一个mock文件
|
44
|
+
#
|
45
|
+
# === 参数解释:
|
46
|
+
# filename: mock文件在MAC上的路径和文件名
|
47
|
+
#
|
48
|
+
# === Example:
|
49
|
+
# Example #1:
|
50
|
+
#
|
51
|
+
def ipush_file(path, file)
|
52
|
+
mount
|
53
|
+
begin
|
54
|
+
path = $isandbox_operator.tmp_folder_name + path
|
55
|
+
path.sub(/\/\//, '/')
|
56
|
+
exec_cmd "cp #{file} #{path}"
|
57
|
+
rescue
|
58
|
+
p "error:#{$!} at:#{$@}"
|
59
|
+
ensure
|
60
|
+
umount
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# === 功能:
|
65
|
+
# 从非越狱iphone拉取一个文件
|
66
|
+
#
|
67
|
+
# === 参数解释:
|
68
|
+
# path: 文件在iphone上的路径和文件名
|
69
|
+
#
|
70
|
+
# === Example:
|
71
|
+
# Example #1:
|
72
|
+
#
|
73
|
+
def ipull_file(path)
|
74
|
+
|
75
|
+
mount
|
76
|
+
begin
|
77
|
+
exec_cmd "cat #{path}" if File.file? path
|
78
|
+
rescue
|
79
|
+
p "error:#{$!} at:#{$@}"
|
80
|
+
ensure
|
81
|
+
umount
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# === 功能:
|
86
|
+
# 从非越狱iphone删除文件
|
87
|
+
#
|
88
|
+
# === 参数解释:
|
89
|
+
# - path: 待删除文件或路径
|
90
|
+
#
|
91
|
+
# === Example:
|
92
|
+
# Example #1:
|
93
|
+
#
|
94
|
+
def iremove_file(path)
|
95
|
+
mount
|
96
|
+
begin
|
97
|
+
path = $isandbox_operator.tmp_folder_name + path
|
98
|
+
if File.directory? path
|
99
|
+
path = path + '/*'
|
100
|
+
path.sub(/\/\//, '/')
|
101
|
+
end
|
102
|
+
exec_cmd "rm -rf #{path}"
|
103
|
+
rescue
|
104
|
+
p "error:#{$!} at:#{$@}"
|
105
|
+
ensure
|
106
|
+
umount
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
##########################
|
111
|
+
# 以下为内部方法,不建议调用 #
|
112
|
+
##########################
|
113
|
+
private
|
114
|
+
|
115
|
+
# === 功能:
|
116
|
+
# 挂载alitrip沙盒
|
117
|
+
# === 参数解释:
|
118
|
+
#
|
119
|
+
# === Example:
|
120
|
+
# Example #1:
|
121
|
+
#
|
122
|
+
def mount
|
123
|
+
$isandbox_operator = ISandboxOperator.new if $has_instance.nil?
|
124
|
+
$isandbox_operator.mount
|
125
|
+
end
|
126
|
+
|
127
|
+
# === 功能:
|
128
|
+
# 卸载alitrip沙盒
|
129
|
+
# === 参数解释:
|
130
|
+
#
|
131
|
+
# === Example:
|
132
|
+
# Example #1:
|
133
|
+
#
|
134
|
+
def umount
|
135
|
+
$isandbox_operator.umount
|
136
|
+
end
|
137
|
+
|
138
|
+
# === 功能:
|
139
|
+
# 执行shell命令
|
140
|
+
# === 参数解释:
|
141
|
+
# cmd: shell命令
|
142
|
+
# === Example:
|
143
|
+
# Example #1:
|
144
|
+
#
|
145
|
+
def exec_cmd(cmd)
|
146
|
+
$isandbox_operator.exec_cmd cmd
|
147
|
+
end
|
148
|
+
|
149
|
+
class ISandboxOperator
|
150
|
+
|
151
|
+
attr_accessor :tmp_folder_name
|
152
|
+
attr_accessor :udid
|
153
|
+
attr_accessor :container
|
154
|
+
|
155
|
+
def initialize
|
156
|
+
fail 'ifuse must be install' unless ifuse_exist?
|
157
|
+
# @caps = ConfigHelper::CONF["appium_driver"]["caps"]
|
158
|
+
# @udid = @caps["udid"]
|
159
|
+
@udid = `idevice_id -l`.split(' ')[0]
|
160
|
+
@container = 'com.taobao.alitrip'
|
161
|
+
$has_instance = self
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
def mount
|
166
|
+
@tmp_folder_name = Time.new.to_i.to_s
|
167
|
+
exec_cmd "mkdir #{@tmp_folder_name}" unless File.exists? @tmp_folder_name
|
168
|
+
exec_cmd "ifuse -u #{@udid} --container #{@container} #{@tmp_folder_name}"
|
169
|
+
@flag_folder = @tmp_folder_name + '/tmp'
|
170
|
+
while true
|
171
|
+
break if File.directory? @flag_folder
|
172
|
+
end
|
173
|
+
@has_mount = true
|
174
|
+
end
|
175
|
+
|
176
|
+
def umount
|
177
|
+
exec_cmd "umount #{@tmp_folder_name}"
|
178
|
+
while true
|
179
|
+
break unless File.directory? @flag_folder
|
180
|
+
end
|
181
|
+
exec_cmd "rm -rf #{@tmp_folder_name}"
|
182
|
+
end
|
183
|
+
|
184
|
+
def exec_cmd(cmd)
|
185
|
+
system cmd
|
186
|
+
end
|
187
|
+
|
188
|
+
## 检测用户电脑上是否存在 ifuse
|
189
|
+
def ifuse_exist?
|
190
|
+
exec_cmd('ifuse -h > /dev/null 2>&1')
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: hanyu
|
5
|
+
# Date:: 2009.12.3
|
6
|
+
|
7
|
+
# ruby的json库因为只处理utf-8字符,我们用起来很不方便
|
8
|
+
# 所以我们使用的是 ruby-json 库
|
9
|
+
# 必须 gem install ruby-json
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
module JsonHelper
|
13
|
+
|
14
|
+
# === 功能:
|
15
|
+
# 封装对JSON的解析
|
16
|
+
#
|
17
|
+
# === 参数解释:
|
18
|
+
# - str JSON字符串
|
19
|
+
#
|
20
|
+
# === Example:
|
21
|
+
# Example #1:
|
22
|
+
# puts ({"fs"=>"非技术","xv"=>[3,4,{3=>4},"飞拉萨"],4=>5}).to_json
|
23
|
+
# #=> {"fs":"非技术","xv":[3,4,{"3":4},"飞拉萨"],"4":5}
|
24
|
+
#
|
25
|
+
# h = parse_json('{"fjsl":"方式来快递费",243:42,"ha":[3,4,"方式来开发","fs"],"非技术":"附件"}')
|
26
|
+
# p h
|
27
|
+
# #=> {"fjsl"=>"方式来快递费", "243"=>42, "ha"=>[3, 4, "方式来开发", "fs"], "非技术"=>"附件"}
|
28
|
+
def parse_json(str)
|
29
|
+
JSON.parse(str)
|
30
|
+
end
|
31
|
+
alias from_json parse_json
|
32
|
+
alias decode_json parse_json
|
33
|
+
|
34
|
+
# === 功能:
|
35
|
+
# 将对象转成json字符串
|
36
|
+
# 本来是不需要的,为了与parse_json对称,特意加的
|
37
|
+
def to_json(obj)
|
38
|
+
obj.to_json
|
39
|
+
end
|
40
|
+
alias encode_json to_json
|
41
|
+
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,168 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: yzm
|
5
|
+
# Date:: 2016-03-25 19:41:22 +0800
|
6
|
+
###########################################
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# 封装mtop结果mock的核心模块
|
11
|
+
module MockHelper
|
12
|
+
|
13
|
+
include JsonHelper
|
14
|
+
include ISandBoxHelper
|
15
|
+
|
16
|
+
# === 功能:
|
17
|
+
# 用于alitrip客户端mock数据,推送mock数据到手机,可多次调用,不会冲掉之前的mock
|
18
|
+
# === 参数解释:
|
19
|
+
# what 此处填string内容/此处填PC上数据文件的路径/Hash
|
20
|
+
# === Example:
|
21
|
+
# Example #1:
|
22
|
+
# mock 'string content'
|
23
|
+
# Example #2:
|
24
|
+
# mock /filepath/on/PC
|
25
|
+
def start_mock(what, fn=nil)
|
26
|
+
|
27
|
+
system 'adb shell dumpsys activity top trip start mtop_mock_response > /dev/null 2>&1'
|
28
|
+
mobile_mock_folder = '/mnt/sdcard/AlitripMockData/'
|
29
|
+
|
30
|
+
if what.class == String
|
31
|
+
begin
|
32
|
+
json_data = JSON.parse what.dup
|
33
|
+
fail 'api is missing' if (json_data['api'].nil? and fn.nil?)
|
34
|
+
if fn
|
35
|
+
file_name = fn
|
36
|
+
else
|
37
|
+
file_name = json_data['api'] + '.json'
|
38
|
+
end
|
39
|
+
|
40
|
+
data = what.to_s
|
41
|
+
rescue
|
42
|
+
begin
|
43
|
+
data = IO.read(what.to_s)
|
44
|
+
json_data = JSON.parse data
|
45
|
+
fail 'api is missing' if (json_data['api'].nil? and fn.nil?)
|
46
|
+
if fn
|
47
|
+
file_name = fn
|
48
|
+
else
|
49
|
+
file_name = json_data['api'] + '.json'
|
50
|
+
end
|
51
|
+
|
52
|
+
rescue
|
53
|
+
raise Exception, 'file not exist'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
elsif what.is_a? Hash
|
57
|
+
fail 'api is missing' if (what['api'].nil? and fn.nil?)
|
58
|
+
|
59
|
+
data = what.to_json.to_s
|
60
|
+
|
61
|
+
if fn
|
62
|
+
file_name = fn
|
63
|
+
else
|
64
|
+
file_name = data['api'] + '.json'
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
mock_path = mobile_mock_folder + file_name
|
70
|
+
begin
|
71
|
+
tmp_file = '.mockFile'
|
72
|
+
File.open(tmp_file, "w+") do |file|
|
73
|
+
file.puts data
|
74
|
+
end
|
75
|
+
system "adb push #{tmp_file} #{mock_path} > /dev/null 2>&1"
|
76
|
+
rescue
|
77
|
+
raise Exception, "error:#{$!} at:#{$@}"
|
78
|
+
ensure
|
79
|
+
system "rm -rf #{tmp_file} > /dev/null 2>&1"
|
80
|
+
end
|
81
|
+
#
|
82
|
+
# push_file mock_path, data
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
# === 功能:
|
87
|
+
# 删除mock数据,只需要调用一次,建议在teardown中调用
|
88
|
+
# === 参数解释:
|
89
|
+
#
|
90
|
+
# === Example:
|
91
|
+
# Example #1:
|
92
|
+
#
|
93
|
+
#
|
94
|
+
def stop_mock()
|
95
|
+
system 'adb shell dumpsys activity top trip stop mtop_mock_response > /dev/null 2>&1'
|
96
|
+
system 'adb shell rm -rf /sdcard/AlitripMockData'
|
97
|
+
end
|
98
|
+
|
99
|
+
# === 功能:
|
100
|
+
# iPhone mock数据关键字,可多次调用,不会冲掉上次的mock
|
101
|
+
# === 参数解释:
|
102
|
+
# what 此处填string内容/此处填PC上数据文件的路径/Hash
|
103
|
+
# === Example:
|
104
|
+
# Example #1:
|
105
|
+
#
|
106
|
+
#
|
107
|
+
def istart_mock(what, fn=nil)
|
108
|
+
@mobile_mock_folder = '/tmp/mtopmock'
|
109
|
+
if what.class == String
|
110
|
+
begin
|
111
|
+
json_data = JSON.parse what.dup
|
112
|
+
data = what.to_s
|
113
|
+
fail 'api is missing' if json_data['api'].nil?
|
114
|
+
if fn
|
115
|
+
file_name = fn
|
116
|
+
else
|
117
|
+
file_name = json_data['api']
|
118
|
+
end
|
119
|
+
|
120
|
+
ipush_data @mobile_mock_folder, data, file_name
|
121
|
+
rescue
|
122
|
+
begin
|
123
|
+
if File.file? what.to_s
|
124
|
+
data = IO.read(what.to_s)
|
125
|
+
json_data = JSON.parse(data)
|
126
|
+
fail 'api is missing' if json_data['api'].nil?
|
127
|
+
if fn
|
128
|
+
file_name = fn
|
129
|
+
else
|
130
|
+
file_name = json_data['api']
|
131
|
+
end
|
132
|
+
|
133
|
+
ipush_data @mobile_mock_folder, data, file_name
|
134
|
+
else
|
135
|
+
fail 'content is illegal'
|
136
|
+
end
|
137
|
+
rescue
|
138
|
+
raise Exception, "error:#{$!} at:#{$@}"
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
elsif what.is_a? Hash
|
143
|
+
fail 'api is missing' if what['api'].nil?
|
144
|
+
data = what.to_json.to_s
|
145
|
+
if fn
|
146
|
+
file_name = fn
|
147
|
+
else
|
148
|
+
file_name = what['api']
|
149
|
+
end
|
150
|
+
|
151
|
+
ipush_data @mobile_mock_folder, data, file_name
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# === 功能:
|
156
|
+
# iPhone 删除mock文件,停止mock数据关键字,只需调用一次,建议在teardown中调用
|
157
|
+
# === 参数解释:
|
158
|
+
#
|
159
|
+
# === Example:
|
160
|
+
# Example #1:
|
161
|
+
#
|
162
|
+
#
|
163
|
+
def istop_mock
|
164
|
+
@mobile_mock_folder = '/tmp/mtopmock'
|
165
|
+
iremove_file @mobile_mock_folder
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|