bicho 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/bicho.gemspec +1 -1
- data/lib/bicho.rb +2 -0
- data/lib/bicho/bug.rb +21 -4
- data/lib/bicho/client.rb +58 -0
- data/lib/bicho/export.rb +15 -0
- data/lib/bicho/history.rb +10 -2
- data/lib/bicho/plugins/novell.rb +15 -7
- data/lib/bicho/query.rb +2 -2
- data/lib/bicho/reports.rb +39 -0
- data/lib/bicho/version.rb +1 -1
- data/test/test_export.rb +155 -0
- data/test/test_novell_plugin.rb +24 -4
- data/test/test_query.rb +5 -1
- data/test/test_reports.rb +25 -0
- data/test/test_version.rb +1 -1
- metadata +13 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 172cfd9dd28c9a8c0dd94951efbe06e25e2cfd2f
|
4
|
+
data.tar.gz: 56d024d2854f96455254aca4ea729d4c40859d58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa19193f97f8fbc740a7d1182786697000a290a0d6c85651689ef9d875542e2161cc6ce552c4c2b1185b577aebae7715699b191cc546f9c04aa76a53c6703b24
|
7
|
+
data.tar.gz: 0a6015ada50404b051a83b40fda44349d80206f10f0f2e972a06ef8f76bf479290c63c38955a39166287cae2474726bc194f4a1a7b3096c59306d09ea6386f22
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* http://github.com/dmacvicar/bicho
|
4
4
|
|
5
5
|
![stable](https://img.shields.io/badge/stability-stable-green.svg)
|
6
|
-
![maintained](https://img.shields.io/maintenance/yes/
|
6
|
+
![maintained](https://img.shields.io/maintenance/yes/2017.svg)
|
7
7
|
[![Build Status](https://travis-ci.org/dmacvicar/bicho.svg?branch=master)](https://travis-ci.org/dmacvicar/bicho)
|
8
8
|
|
9
9
|
## Introduction
|
@@ -110,11 +110,11 @@ default: mysite
|
|
110
110
|
Plugins are classes in the module Bicho::Plugins. They can implement hooks that are
|
111
111
|
called at different points of execution.
|
112
112
|
|
113
|
-
* default_site_url_hook
|
113
|
+
* `default_site_url_hook`
|
114
114
|
|
115
115
|
If no site url is provided the last one provided by a plugin will be used.
|
116
116
|
|
117
|
-
* transform_site_url_hook
|
117
|
+
* `transform_site_url_hook`
|
118
118
|
|
119
119
|
This hook is called to modify the main site url (eg: http://bugzilla.suse.com).
|
120
120
|
Use it when a plugin wants to provide an alternative url to a well-known bugzilla or
|
@@ -122,11 +122,15 @@ called at different points of execution.
|
|
122
122
|
Plugin order is not defined so make sure your plugin focuses in one type of shortcut
|
123
123
|
as another plugin can also change your returned value in their hooks.
|
124
124
|
|
125
|
-
* transform_api_url_hook
|
125
|
+
* `transform_api_url_hook`
|
126
126
|
|
127
127
|
The API url is derived from the site url, however some bugzilla installations may have
|
128
128
|
different servers or endpoints.
|
129
129
|
|
130
|
+
* `transform_xmlrpc_client_hook`
|
131
|
+
|
132
|
+
This hook allows to modify the `XMLRPC::Client` object.
|
133
|
+
|
130
134
|
### Commands
|
131
135
|
|
132
136
|
See the +Command+ class to implement more commands.
|
data/bicho.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency('rake')
|
21
21
|
s.add_development_dependency('minitest')
|
22
22
|
s.add_development_dependency('minitest-reporters')
|
23
|
-
s.add_development_dependency('rubocop')
|
23
|
+
s.add_development_dependency('rubocop', '= 0.41.2')
|
24
24
|
|
25
25
|
s.rubyforge_project = 'bicho'
|
26
26
|
|
data/lib/bicho.rb
CHANGED
data/lib/bicho/bug.rb
CHANGED
@@ -58,7 +58,7 @@ module Bicho
|
|
58
58
|
|
59
59
|
def method_missing(method_name, *_args)
|
60
60
|
return super unless @data.key?(method_name.to_s)
|
61
|
-
|
61
|
+
self[method_name]
|
62
62
|
end
|
63
63
|
|
64
64
|
def respond_to_missing?(method_name, _include_private = false)
|
@@ -76,9 +76,13 @@ module Bicho
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def [](name, subname = nil)
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
value = @data[name.to_s]
|
80
|
+
value = value[subname.to_s] if subname # for 'internals' properties
|
81
|
+
if value.is_a?(XMLRPC::DateTime)
|
82
|
+
value.to_time
|
83
|
+
else
|
84
|
+
value
|
85
|
+
end
|
82
86
|
end
|
83
87
|
|
84
88
|
# URL where the bug can be viewed
|
@@ -97,10 +101,23 @@ module Bicho
|
|
97
101
|
@client.get_attachments(id)
|
98
102
|
end
|
99
103
|
|
104
|
+
# Add an attachment to the bug
|
105
|
+
# For the params description, see the Client.add_attachment method.
|
106
|
+
#
|
107
|
+
# @return [ID] of the new attachment
|
108
|
+
def add_attachment(summary, file, **kwargs)
|
109
|
+
@client.add_attachment(summary, file, id, **kwargs).first
|
110
|
+
end
|
111
|
+
|
100
112
|
# @param format_string For Kernel#sprintf; named params supplied by the bug
|
101
113
|
def format(format_string)
|
102
114
|
sym_data = Hash[@data.to_a.map { |k, v| [k.to_sym, v] }]
|
103
115
|
Kernel.format(format_string, sym_data)
|
104
116
|
end
|
117
|
+
|
118
|
+
# @return [Hash]
|
119
|
+
def to_h
|
120
|
+
Hash[@data.to_a.map { |k, _| [k.to_sym, self[k.to_sym]] }]
|
121
|
+
end
|
105
122
|
end
|
106
123
|
end
|
data/lib/bicho/client.rb
CHANGED
@@ -131,6 +131,12 @@ module Bicho
|
|
131
131
|
|
132
132
|
@client = XMLRPC::Client.new_from_uri(@api_url.to_s, nil, 900)
|
133
133
|
@client.set_debug
|
134
|
+
@plugins.each do |pl_instance|
|
135
|
+
# Modify API url
|
136
|
+
if pl_instance.respond_to?(:transform_xmlrpc_client_hook)
|
137
|
+
pl_instance.transform_xmlrpc_client_hook(@client, logger)
|
138
|
+
end
|
139
|
+
end
|
134
140
|
|
135
141
|
# User.login sets the credentials cookie for subsequent calls
|
136
142
|
if @client.user && @client.password
|
@@ -180,6 +186,27 @@ module Bicho
|
|
180
186
|
ret['version']
|
181
187
|
end
|
182
188
|
|
189
|
+
# Create a bug
|
190
|
+
#
|
191
|
+
# @param product - the name of the product the bug is being filed against
|
192
|
+
# @param component - the name of a component in the product above.
|
193
|
+
# @param summary - a brief description of the bug being filed.
|
194
|
+
# @param version - version of the product above; the version the bug was found in.
|
195
|
+
# @param **kwargs - keyword-args containing optional/defaulted params
|
196
|
+
#
|
197
|
+
# Return the new bug ID
|
198
|
+
def create_bug(product, component, summary, version, **kwargs)
|
199
|
+
params = {}
|
200
|
+
params = params.merge(kwargs)
|
201
|
+
params[:product] = product
|
202
|
+
params[:component] = component
|
203
|
+
params[:summary] = summary
|
204
|
+
params[:version] = version
|
205
|
+
ret = @client.call('Bug.create', params)
|
206
|
+
handle_faults(ret)
|
207
|
+
ret['id']
|
208
|
+
end
|
209
|
+
|
183
210
|
# Search for a bug
|
184
211
|
#
|
185
212
|
# +query+ has to be either a +Query+ object or
|
@@ -319,5 +346,36 @@ module Bicho
|
|
319
346
|
end
|
320
347
|
end.flatten
|
321
348
|
end
|
349
|
+
|
350
|
+
# Add an attachment to bugs with given ids
|
351
|
+
#
|
352
|
+
# Params:
|
353
|
+
# @param summary - a short string describing the attachment
|
354
|
+
# @param file - [File] object to attach
|
355
|
+
# @param *ids - a list of bug ids to which the attachment will be added
|
356
|
+
# @param **kwargs - optional keyword-args that may contain:
|
357
|
+
# - content_type - content type of the attachment (if ommited,
|
358
|
+
# 'application/octet-stream' will be used)
|
359
|
+
# - file_name - name of the file (if ommited, the base name of the
|
360
|
+
# provided file will be used)
|
361
|
+
# - patch? - flag saying that the attachment is a patch
|
362
|
+
# - private? - flag saying that the attachment is private
|
363
|
+
# - comment
|
364
|
+
#
|
365
|
+
# @return [Array<ID>] a list of the attachment id(s) created.
|
366
|
+
def add_attachment(summary, file, *ids, **kwargs)
|
367
|
+
params = {}
|
368
|
+
params[:ids] = ids
|
369
|
+
params[:summary] = summary
|
370
|
+
params[:content_type] = kwargs.fetch(:content_type, 'application/octet-stream')
|
371
|
+
params[:file_name] = kwargs.fetch(:file_name, File.basename(file))
|
372
|
+
params[:is_patch] = kwargs[:patch?] if kwargs[:patch?]
|
373
|
+
params[:is_private] = kwargs[:private?] if kwargs[:private?]
|
374
|
+
params[:comment] = kwargs[:comment] if kwargs[:comment]
|
375
|
+
params[:data] = XMLRPC::Base64.new(file.read)
|
376
|
+
ret = @client.call('Bug.add_attachment', params)
|
377
|
+
handle_faults(ret)
|
378
|
+
ret['ids']
|
379
|
+
end
|
322
380
|
end
|
323
381
|
end
|
data/lib/bicho/export.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Bicho
|
4
|
+
# Utility methods for exporting bugs to other systems
|
5
|
+
module Export
|
6
|
+
# Exports full data of a bug to json, including some extended
|
7
|
+
# calculated attributes.
|
8
|
+
def self.to_json(bug)
|
9
|
+
bug_h = bug.to_h
|
10
|
+
bug_h['history'] = bug.history.changesets.map(&:to_h)
|
11
|
+
bug_h['resolution_time'] = Bicho::Reports.resolution_time(bug)
|
12
|
+
JSON.generate(bug_h)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/bicho/history.rb
CHANGED
@@ -52,6 +52,10 @@ module Bicho
|
|
52
52
|
@client = client
|
53
53
|
@data = data
|
54
54
|
end
|
55
|
+
|
56
|
+
def to_h
|
57
|
+
@data
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
# A collection of related changes.
|
@@ -67,7 +71,7 @@ module Bicho
|
|
67
71
|
|
68
72
|
# return [Date] The date the bug activity/change happened.
|
69
73
|
def timestamp
|
70
|
-
@data['when'].
|
74
|
+
@data['when'].to_time
|
71
75
|
end
|
72
76
|
|
73
77
|
# @return [String] The login name of the user who performed the bug change
|
@@ -89,12 +93,16 @@ module Bicho
|
|
89
93
|
|
90
94
|
def to_s
|
91
95
|
buffer = StringIO.new
|
92
|
-
buffer << "#{
|
96
|
+
buffer << "#{timestamp}- #{who}\n"
|
93
97
|
changes.each do |diff|
|
94
98
|
buffer << "#{diff}\n"
|
95
99
|
end
|
96
100
|
buffer.string
|
97
101
|
end
|
102
|
+
|
103
|
+
def to_h
|
104
|
+
{ who: who, timestamp: timestamp, changes: changes.map(&:to_h) }
|
105
|
+
end
|
98
106
|
end
|
99
107
|
|
100
108
|
# A collection of Changesets associated with a bug
|
data/lib/bicho/plugins/novell.rb
CHANGED
@@ -39,6 +39,8 @@ module Bicho
|
|
39
39
|
class Novell
|
40
40
|
OSCRC_CREDENTIALS = 'https://api.opensuse.org'.freeze unless defined? OSCRC_CREDENTIALS
|
41
41
|
DEFAULT_OSCRC_PATH = File.join(ENV['HOME'], '.oscrc') unless defined? DEFAULT_OSCRC_PATH
|
42
|
+
DOMAINS = ['bugzilla.novell.com', 'bugzilla.suse.com'].freeze
|
43
|
+
XMLRPC_DOMAINS = ['apibugzilla.novell.com', 'apibugzilla.suse.com'].freeze
|
42
44
|
|
43
45
|
class << self
|
44
46
|
attr_writer :oscrc_path
|
@@ -75,25 +77,31 @@ module Bicho
|
|
75
77
|
end
|
76
78
|
|
77
79
|
def transform_api_url_hook(url, logger)
|
78
|
-
|
79
|
-
return url unless domains.map { |domain| url.host.include?(domain) }.any?
|
80
|
+
return url unless DOMAINS.map { |domain| url.host.include?(domain) }.any?
|
80
81
|
|
81
82
|
begin
|
82
|
-
auth = Novell.oscrc_credentials
|
83
|
-
|
84
83
|
url = url.clone
|
85
|
-
url.user = auth[:user]
|
86
|
-
url.password = auth[:password]
|
87
84
|
url.host = url.host.gsub(/bugzilla\.novell.com/, 'apibugzilla.novell.com')
|
88
85
|
url.host = url.host.gsub(/bugzilla\.suse.com/, 'apibugzilla.suse.com')
|
89
86
|
url.scheme = 'https'
|
90
87
|
|
91
|
-
logger.debug("#{self} : Rewrote url to '#{url
|
88
|
+
logger.debug("#{self} : Rewrote url to '#{url}'")
|
92
89
|
rescue StandardError => e
|
93
90
|
logger.warn e
|
94
91
|
end
|
95
92
|
url
|
96
93
|
end
|
94
|
+
|
95
|
+
def transform_xmlrpc_client_hook(client, logger)
|
96
|
+
return unless XMLRPC_DOMAINS.map { |domain| client.http.address.include?(domain) }.any?
|
97
|
+
|
98
|
+
auth = Novell.oscrc_credentials
|
99
|
+
client.user = auth[:user]
|
100
|
+
client.password = auth[:password]
|
101
|
+
logger.debug("#{self} : updated XMLRPC client with oscrc auth information")
|
102
|
+
rescue StandardError => e
|
103
|
+
logger.error e
|
104
|
+
end
|
97
105
|
end
|
98
106
|
end
|
99
107
|
end
|
data/lib/bicho/query.rb
CHANGED
@@ -76,9 +76,9 @@ module Bicho
|
|
76
76
|
Bicho::SEARCH_FIELDS.map(&:first).include?(method_name) || super
|
77
77
|
end
|
78
78
|
|
79
|
-
# Shortcut equivalent to status new, assigned, needinfo and
|
79
|
+
# Shortcut equivalent to status new, assigned, needinfo, reopened, confirmed, and in_progress
|
80
80
|
def open
|
81
|
-
status(:new).status(:assigned).status(:needinfo).status(:reopened)
|
81
|
+
status(:new).status(:assigned).status(:needinfo).status(:reopened).status(:confirmed).status(:in_progress)
|
82
82
|
end
|
83
83
|
|
84
84
|
# Shortcut, equivalent to
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Bicho
|
2
|
+
# Utility methods for reporting on bugs
|
3
|
+
module Reports
|
4
|
+
# When was the bug finally set to a resolved state
|
5
|
+
#
|
6
|
+
# Resolution time is nil if the bug is not resolved yet.
|
7
|
+
def self.resolution_time(bug)
|
8
|
+
t = nil
|
9
|
+
bug.history.sort_by(&:timestamp).each do |cs|
|
10
|
+
cs.changes.each do |c|
|
11
|
+
t = cs.timestamp if c.field_name == 'status' &&
|
12
|
+
c.added == 'RESOLVED'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
t
|
16
|
+
end
|
17
|
+
|
18
|
+
# returns the ranges a bug is with statuses
|
19
|
+
def self.ranges_with_statuses(bug, *statuses)
|
20
|
+
ranges = []
|
21
|
+
current_start = bug.creation_time
|
22
|
+
current_status = nil
|
23
|
+
bug.history.sort_by(&:timestamp).each do |cs|
|
24
|
+
cs.changes.each do |c|
|
25
|
+
next unless c.field_name == 'status'
|
26
|
+
|
27
|
+
current_status = c.removed if current_status.nil?
|
28
|
+
ranges.push(current_start..cs.timestamp) if statuses.include?(c.removed)
|
29
|
+
|
30
|
+
current_start = cs.timestamp
|
31
|
+
current_status = c.added
|
32
|
+
end
|
33
|
+
end
|
34
|
+
# last status is still valid
|
35
|
+
ranges.push(current_start..Time.now) if statuses.include?(current_status)
|
36
|
+
ranges
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/bicho/version.rb
CHANGED
data/test/test_export.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
BUG_ES_EXPORT = <<-EOF.freeze
|
4
|
+
{
|
5
|
+
"priority": "Normal",
|
6
|
+
"blocks": [
|
7
|
+
|
8
|
+
],
|
9
|
+
"creator": "kekun.plazas@laposte.net",
|
10
|
+
"last_change_time": "2017-02-22 20:48:43 UTC",
|
11
|
+
"is_cc_accessible": true,
|
12
|
+
"keywords": [
|
13
|
+
|
14
|
+
],
|
15
|
+
"cc": [
|
16
|
+
"kekun.plazas@laposte.net",
|
17
|
+
"mcatanzaro@gnome.org"
|
18
|
+
],
|
19
|
+
"url": "",
|
20
|
+
"assigned_to": "gnome-games-maint@gnome.bugs",
|
21
|
+
"see_also": [
|
22
|
+
|
23
|
+
],
|
24
|
+
"groups": [
|
25
|
+
|
26
|
+
],
|
27
|
+
"id": 777777,
|
28
|
+
"creation_time": "2017-01-26 08:46:00 UTC",
|
29
|
+
"whiteboard": "",
|
30
|
+
"qa_contact": "gnome-games-maint@gnome.bugs",
|
31
|
+
"depends_on": [
|
32
|
+
|
33
|
+
],
|
34
|
+
"resolution": "FIXED",
|
35
|
+
"classification": "Core",
|
36
|
+
"op_sys": "Linux",
|
37
|
+
"status": "RESOLVED",
|
38
|
+
"cf_gnome_target": "---",
|
39
|
+
"cf_gnome_version": "---",
|
40
|
+
"summary": "Game Boy games not detected",
|
41
|
+
"is_open": false,
|
42
|
+
"platform": "Other",
|
43
|
+
"severity": "normal",
|
44
|
+
"flags": [
|
45
|
+
|
46
|
+
],
|
47
|
+
"version": "unspecified",
|
48
|
+
"component": "general",
|
49
|
+
"is_creator_accessible": true,
|
50
|
+
"product": "gnome-games",
|
51
|
+
"is_confirmed": true,
|
52
|
+
"target_milestone": "---",
|
53
|
+
"history": [
|
54
|
+
{
|
55
|
+
"who": "kekun.plazas@laposte.net",
|
56
|
+
"timestamp": "2017-01-26 09:03:10 UTC",
|
57
|
+
"changes": [
|
58
|
+
{
|
59
|
+
"removed": "",
|
60
|
+
"added": "kekun.plazas@laposte.net",
|
61
|
+
"field_name": "cc"
|
62
|
+
}
|
63
|
+
]
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"who": "kekun.plazas@laposte.net",
|
67
|
+
"timestamp": "2017-01-26 09:05:34 UTC",
|
68
|
+
"changes": [
|
69
|
+
{
|
70
|
+
"attachment_id": 344292,
|
71
|
+
"removed": "0",
|
72
|
+
"added": "1",
|
73
|
+
"field_name": "attachments.isobsolete"
|
74
|
+
}
|
75
|
+
]
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"who": "kekun.plazas@laposte.net",
|
79
|
+
"timestamp": "2017-01-26 09:06:09 UTC",
|
80
|
+
"changes": [
|
81
|
+
{
|
82
|
+
"removed": "NEW",
|
83
|
+
"added": "RESOLVED",
|
84
|
+
"field_name": "status"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"removed": "",
|
88
|
+
"added": "FIXED",
|
89
|
+
"field_name": "resolution"
|
90
|
+
}
|
91
|
+
]
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"who": "kekun.plazas@laposte.net",
|
95
|
+
"timestamp": "2017-01-26 09:06:13 UTC",
|
96
|
+
"changes": [
|
97
|
+
{
|
98
|
+
"attachment_id": 344293,
|
99
|
+
"removed": "none",
|
100
|
+
"added": "committed",
|
101
|
+
"field_name": "attachments.gnome_attachment_status"
|
102
|
+
}
|
103
|
+
]
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"who": "kekun.plazas@laposte.net",
|
107
|
+
"timestamp": "2017-01-26 09:06:16 UTC",
|
108
|
+
"changes": [
|
109
|
+
{
|
110
|
+
"attachment_id": 344294,
|
111
|
+
"removed": "none",
|
112
|
+
"added": "committed",
|
113
|
+
"field_name": "attachments.gnome_attachment_status"
|
114
|
+
}
|
115
|
+
]
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"who": "kekun.plazas@laposte.net",
|
119
|
+
"timestamp": "2017-01-26 11:06:35 UTC",
|
120
|
+
"changes": [
|
121
|
+
{
|
122
|
+
"attachment_id": 344303,
|
123
|
+
"removed": "none",
|
124
|
+
"added": "committed",
|
125
|
+
"field_name": "attachments.gnome_attachment_status"
|
126
|
+
}
|
127
|
+
]
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"who": "mcatanzaro@gnome.org",
|
131
|
+
"timestamp": "2017-02-22 20:40:19 UTC",
|
132
|
+
"changes": [
|
133
|
+
{
|
134
|
+
"removed": "",
|
135
|
+
"added": "mcatanzaro@gnome.org",
|
136
|
+
"field_name": "cc"
|
137
|
+
}
|
138
|
+
]
|
139
|
+
}
|
140
|
+
],
|
141
|
+
"resolution_time": "2017-01-26 09:06:09 UTC"
|
142
|
+
}
|
143
|
+
EOF
|
144
|
+
|
145
|
+
# Test small utilities
|
146
|
+
class ExportTest < Minitest::Test
|
147
|
+
def test_to_json
|
148
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.gnome.org')
|
149
|
+
bug = Bicho.client.get_bug(777777)
|
150
|
+
assert_equal(
|
151
|
+
JSON.dump(JSON.load(BUG_ES_EXPORT)),
|
152
|
+
Bicho::Export.to_json(bug)
|
153
|
+
)
|
154
|
+
end
|
155
|
+
end
|
data/test/test_novell_plugin.rb
CHANGED
@@ -5,22 +5,42 @@ require 'logger'
|
|
5
5
|
# Test for the plugin supporting the Novell/SUSE bugzilla authentication
|
6
6
|
class NovellPluginTest < Minitest::Test
|
7
7
|
def test_url_replacement
|
8
|
-
|
9
|
-
log = Logger.new(w)
|
8
|
+
creds = { user: 'test', password: 'test' }
|
10
9
|
%w(novell suse).each do |domain|
|
11
|
-
|
10
|
+
r, w = IO.pipe
|
11
|
+
log = Logger.new(w)
|
12
12
|
Bicho::Plugins::Novell.stub :oscrc_credentials, creds do
|
13
13
|
plugin = Bicho::Plugins::Novell.new
|
14
14
|
url = URI.parse("http://bugzilla.#{domain}.com")
|
15
15
|
site_url = plugin.transform_site_url_hook(url, log)
|
16
16
|
api_url = plugin.transform_api_url_hook(url, log)
|
17
17
|
assert_equal(site_url.to_s, "http://bugzilla.#{domain}.com")
|
18
|
-
assert_equal(api_url.to_s, "https://
|
18
|
+
assert_equal(api_url.to_s, "https://apibugzilla.#{domain}.com")
|
19
19
|
assert_match(/Rewrote url/, r.gets)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_xmlrpcclient_replacement
|
25
|
+
creds = { user: 'test', password: 'test' }
|
26
|
+
%w(novell suse).each do |domain|
|
27
|
+
Bicho::Plugins::Novell.stub :oscrc_credentials, creds do
|
28
|
+
r, w = IO.pipe
|
29
|
+
log = Logger.new(w)
|
30
|
+
|
31
|
+
plugin = Bicho::Plugins::Novell.new
|
32
|
+
url = URI.parse("http://bugzilla.#{domain}.com")
|
33
|
+
api_url = plugin.transform_api_url_hook(url, log)
|
34
|
+
client = XMLRPC::Client.new_from_uri(api_url.to_s, nil, 900)
|
35
|
+
plugin.transform_xmlrpc_client_hook(client, log)
|
36
|
+
w.close
|
37
|
+
assert_equal('test', client.user, 'xmlrpc client username should be set')
|
38
|
+
assert_equal('test', client.password, 'xmlrpc client password should be set')
|
39
|
+
assert_match(/updated XMLRPC client with oscrc auth information/, r.read)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
24
44
|
def test_oscrc_parsing
|
25
45
|
oscrc = <<EOS
|
26
46
|
[https://api.opensuse.org]
|
data/test/test_query.rb
CHANGED
@@ -2,6 +2,10 @@ require_relative 'helper'
|
|
2
2
|
|
3
3
|
# Test query DSL
|
4
4
|
class QueryTest < Minitest::Test
|
5
|
+
def setup
|
6
|
+
Bicho.client = nil
|
7
|
+
end
|
8
|
+
|
5
9
|
def test_active_record_style
|
6
10
|
# No client set yet
|
7
11
|
assert_raises RuntimeError do
|
@@ -23,7 +27,7 @@ class QueryTest < Minitest::Test
|
|
23
27
|
|
24
28
|
def test_query_shortcuts
|
25
29
|
ret = Bicho::Query.new.open
|
26
|
-
assert_equal({ 'status' => [:new, :assigned, :needinfo, :reopened] }, ret.query_map)
|
30
|
+
assert_equal({ 'status' => [:new, :assigned, :needinfo, :reopened, :confirmed, :in_progress] }, ret.query_map)
|
27
31
|
end
|
28
32
|
|
29
33
|
def teardown
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
# Test reports on bugs
|
4
|
+
class ReportsTest < Minitest::Test
|
5
|
+
def test_resolution_date
|
6
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.gnome.org')
|
7
|
+
bug = Bicho.client.get_bug(777777)
|
8
|
+
ts = Bicho::Reports.resolution_time(bug)
|
9
|
+
assert_equal(Time.parse('2017-01-26 09:06:09 UTC'), ts)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_ranges_with_statuses
|
13
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.gnome.org')
|
14
|
+
bug = Bicho.client.get_bug(312619)
|
15
|
+
ranges = Bicho::Reports.ranges_with_statuses(bug, 'NEEDINFO')
|
16
|
+
assert_equal(
|
17
|
+
[Time.parse('2005-12-31 21:56:36 UTC')..Time.parse('2006-04-11 19:22:41 UTC')], ranges
|
18
|
+
)
|
19
|
+
|
20
|
+
ranges = Bicho::Reports.ranges_with_statuses(bug, 'NEEDINFO', 'RESOLVED')
|
21
|
+
assert_equal(Time.parse('2005-12-31 21:56:36 UTC')..Time.parse('2006-04-11 19:22:41 UTC'), ranges[0])
|
22
|
+
assert_equal(Time.parse('2006-04-11 19:22:41 UTC'), ranges[1].begin)
|
23
|
+
assert(Time.now - ranges[1].end < 60)
|
24
|
+
end
|
25
|
+
end
|
data/test/test_version.rb
CHANGED
@@ -11,7 +11,7 @@ class VersionTest < Minitest::Test
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_version_suse
|
14
|
-
Bicho.client = Bicho::Client.new('https://bugzilla.
|
14
|
+
Bicho.client = Bicho::Client.new('https://bugzilla.opensuse.org')
|
15
15
|
|
16
16
|
ret = Bicho.client.version
|
17
17
|
# https://bugzilla.suse.com is at 4.4.6 as of Jan/2015
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bicho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duncan Mac-Vicar P.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.41.2
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.41.2
|
125
125
|
description: Library to access bugzilla
|
126
126
|
email:
|
127
127
|
- dmacvicar@suse.de
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/bicho/cli/commands/version.rb
|
151
151
|
- lib/bicho/client.rb
|
152
152
|
- lib/bicho/common_client.rb
|
153
|
+
- lib/bicho/export.rb
|
153
154
|
- lib/bicho/ext/logger_colors.rb
|
154
155
|
- lib/bicho/history.rb
|
155
156
|
- lib/bicho/logging.rb
|
@@ -157,12 +158,15 @@ files:
|
|
157
158
|
- lib/bicho/plugins/novell.rb
|
158
159
|
- lib/bicho/plugins/user.rb
|
159
160
|
- lib/bicho/query.rb
|
161
|
+
- lib/bicho/reports.rb
|
160
162
|
- lib/bicho/version.rb
|
161
163
|
- test/helper.rb
|
162
164
|
- test/test_attachments.rb
|
165
|
+
- test/test_export.rb
|
163
166
|
- test/test_history.rb
|
164
167
|
- test/test_novell_plugin.rb
|
165
168
|
- test/test_query.rb
|
169
|
+
- test/test_reports.rb
|
166
170
|
- test/test_user_plugin.rb
|
167
171
|
- test/test_version.rb
|
168
172
|
homepage: http://github.com/dmacvicar/bicho
|
@@ -185,16 +189,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
189
|
version: '0'
|
186
190
|
requirements: []
|
187
191
|
rubyforge_project: bicho
|
188
|
-
rubygems_version: 2.
|
192
|
+
rubygems_version: 2.6.11
|
189
193
|
signing_key:
|
190
194
|
specification_version: 4
|
191
195
|
summary: Library to access bugzilla
|
192
196
|
test_files:
|
193
197
|
- test/helper.rb
|
194
198
|
- test/test_attachments.rb
|
199
|
+
- test/test_export.rb
|
195
200
|
- test/test_history.rb
|
196
201
|
- test/test_novell_plugin.rb
|
197
202
|
- test/test_query.rb
|
203
|
+
- test/test_reports.rb
|
198
204
|
- test/test_user_plugin.rb
|
199
205
|
- test/test_version.rb
|
200
|
-
has_rdoc:
|