Browse Source

improve coverage + removal of 'self-made' tests in the modules __main__

tags/6.0
Sandro Tosi 10 years ago
parent
commit
e6804ae9ba
7 changed files with 39 additions and 33 deletions
  1. +0
    -10
      reportbug/checkversions.py
  2. +0
    -5
      reportbug/debianbts.py
  3. +0
    -13
      reportbug/submit.py
  4. +0
    -5
      reportbug/urlutils.py
  5. +12
    -0
      test/test_checkversions.py
  6. +16
    -0
      test/test_debianbts.py
  7. +11
    -0
      test/test_urlutils.py

+ 0
- 10
reportbug/checkversions.py View File

@@ -269,13 +269,3 @@ def check_available(package, version, timeout, dists=None,
newer += 1
too_new = (newer and newer == len(avail))
return new, too_new

if __name__=='__main__':
gc.set_debug(gc.DEBUG_LEAK)
print get_newqueue_available('reportbug', timeout=60)
print gc.garbage
#print check_available('reportbug', timeout=60, '3.7', arch='s390')
#print check_available('openssh-server', '1:4.2p1-8', arch='i386')
#print check_available('openssh-server', '1:4.2p1-8', arch='kfreebsd-i386')
time.sleep(1000)
#print check_available('dpkg', '1.10.2', arch='sparc')

+ 0
- 5
reportbug/debianbts.py View File

@@ -1245,8 +1245,3 @@ def get_report(number, timeout, system='debian', mirrors=None,
class NullParser(sgmllib.SGMLParser):
def __init__(self):
sgmllib.SGMLParser.__init__(self)

if __name__ == '__main__':
data = get_cgi_reports('reportbug', timeout=60)
pprint.pprint(data)
time.sleep(1000)

+ 0
- 13
reportbug/submit.py View File

@@ -500,16 +500,3 @@ within an hour; if you haven't received a confirmation, then the bug reporting p
# Message is misleading if an MUA is used.
ewrite("A copy of the report is stored as: %s\n" % filename)
return

def main():
'o'

if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
ewrite("\nreportbug: exiting due to user interrupt.\n")
except debianbts.Error, x:
ewrite('error accessing BTS: %s\n' % x)

# vim:ts=8:sw=4:expandtab

+ 0
- 5
reportbug/urlutils.py View File

@@ -182,8 +182,3 @@ def launch_browser(url):
cmd = "%s %s" % (CONSOLEBROWSER, commands.mkarg(url))

os.system(cmd)

if __name__ == '__main__':
page = open_url('http://bugs.debian.org/reportbug')
content = page.read()
print page.info().headers

+ 12
- 0
test/test_checkversions.py View File

@@ -13,5 +13,17 @@ class TestCheckversions(unittest2.TestCase):

self.assertEqual(checkversions.compare_versions('123', None), 0)
self.assertEqual(checkversions.compare_versions('1.2.3', '1.2.3'), 0)
self.assertEqual(checkversions.compare_versions(None, None), 0)

self.assertEqual(checkversions.compare_versions('1.2.4', '1.2.3'), -1)

def test_later_version(self):
# mock the test_compare_Versions() test

self.assertEqual(checkversions.later_version('1.2.3', '1.2.4'), '1.2.4')

self.assertEqual(checkversions.later_version('123', None), '123')
self.assertEqual(checkversions.later_version('1.2.3', '1.2.3'), '1.2.3')
self.assertIsNone(checkversions.later_version(None, None))

self.assertEqual(checkversions.compare_versions('1.2.4', '1.2.3'), '1.2.4')

+ 16
- 0
test/test_debianbts.py View File

@@ -66,3 +66,19 @@ class TestInfofunc(unittest2.TestCase):
def test_generic_infofunc(self):
info = debianbts.generic_infofunc()
self.assertIn('Architecture:', info)

class TestMiscFunctions(unittest2.TestCase):

def test_yn_bool(self):
self.assertEqual(debianbts.yn_bool(None), 'no')
self.assertEqual(debianbts.yn_bool('no'), 'no')
self.assertEqual(debianbts.yn_bool('yes'), 'yes')
self.assertEqual(debianbts.yn_bool('dummy string'), 'yes')


#class TestNetwork(unittest2.TestCase):
#
# def test_get_cgi_reports(self):
#
# data = debianbts.get_cgi_reports('reportbug', timeout=60)
# self.assertGreater(len(data), 0)

+ 11
- 0
test/test_urlutils.py View File

@@ -0,0 +1,11 @@
import unittest2

from reportbug import urlutils

class TestNetwork(unittest2.TestCase):

def test_open_url(self):

page = urlutils.open_url('http://bugs.debian.org/reportbug')
content = page.read()
self.assertIsNotNone(page.info().headers)

Loading…
Cancel
Save