GithubHelp home page GithubHelp logo

psss / python-nitrate Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 22.0 547 KB

Python API for the Nitrate test case management system

License: GNU Lesser General Public License v2.1

Python 99.42% Makefile 0.58%

python-nitrate's People

Contributors

atodorov avatar dhodovsk avatar fholec avatar frozencemetery avatar lbarcziova avatar leospol avatar lukaszachy avatar psss avatar stepnem avatar t184256 avatar thrix avatar zelenymartin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-nitrate's Issues

caching: pickle.load() fails

Conditions

Cache level 3 needs to be enabled in ~/.nitrate:

[cache]
level = 3

Test suite fail

python -m nitrate.tests
Output from test suite (needs to be run as whole test suite - no just the CasePlan test case - it does not fail)

CasePlan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sort key update ... ERROR

======================================================================
ERROR: Sort key update
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mzeleny/Work/git/python-nitrate/venv/lib64/python3.8/site-packages/nitrate/tests.py", line 1230, in test_sortkey_update
    cache.load()
  File "/home/mzeleny/Work/git/python-nitrate/venv/lib64/python3.8/site-packages/nitrate/cache.py", line 298, in load
    data = pickle.load(input_file)
TypeError: __new__() missing 1 required positional argument: 'object'

----------------------------------------------------------------------
Ran 1 test in 1.360s

FAILED (errors=1)

Production using fail

Traceback (most recent call last):
  File "./progress-generator.py", line 296, in <module>
    main()
  File "./progress-generator.py", line 282, in main
    dontRemoveCompose.append(updateComposeDetailPage(processedConfig['TCMS_STATUSES'], wikiPage, compose, tag))
  File "./progress-generator.py", line 223, in updateComposeDetailPage
    tcmsPart, exitCode = getTcmsInfo(tcmsStatuses, compose, tag)
  File "./progress-generator.py", line 126, in getTcmsInfo
    TRs=nitrate.TestRun.search(build__name=build, tag__name__contains=tag)
  File "/usr/lib/python3.8/site-packages/nitrate/mutable.py", line 538, in search
    return [TestRun(hash)
  File "/usr/lib/python3.8/site-packages/nitrate/mutable.py", line 538, in <listcomp>
    return [TestRun(hash)
  File "/usr/lib/python3.8/site-packages/nitrate/base.py", line 311, in __new__
    Cache()
  File "/usr/lib/python3.8/site-packages/nitrate/cache.py", line 194, in __new__
    cls._instance.__init__(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/nitrate/cache.py", line 203, in __init__
    self.enter(filename)
  File "/usr/lib/python3.8/site-packages/nitrate/cache.py", line 388, in enter
    self.load()
  File "/usr/lib/python3.8/site-packages/nitrate/cache.py", line 298, in load
    data = pickle.load(input_file)
TypeError: __new__() missing 1 required positional argument: 'object'

teiid.py incompatible with python3

On line 100, there is a conversion of item to int, if it's long. However, long has been removed from python3, causing a syntax error on the line in question:

...
File "/usr/lib/python3.7/site-packages/nitrate/init.py", line 67, in
from nitrate.base import Nitrate
File "/usr/lib/python3.7/site-packages/nitrate/base.py", line 45, in
import nitrate.teiid as teiid
File "/usr/lib/python3.7/site-packages/nitrate/teiid.py", line 99
rows = [item for item in row] for row in rows]
^
SyntaxError: invalid syntax

Traceback when importing from immutable with python2

Traceback (most recent call last):
File "./tcms-sort", line 5, in
import nitrate
File "/usr/lib/python2.7/site-packages/nitrate/init.py", line 67, in
from nitrate.base import Nitrate
File "/usr/lib/python2.7/site-packages/nitrate/nitrate/init.py", line 67, in
from nitrate.base import Nitrate
File "/usr/lib/python2.7/site-packages/nitrate/base.py", line 426, in
from nitrate.cache import Cache
File "/usr/lib/python2.7/site-packages/nitrate/nitrate/cache.py", line 121, in
import nitrate.immutable as immutable
File "/usr/lib/python2.7/site-packages/nitrate/immutable.py", line 32, in
from nitrate.base import Nitrate, NitrateNone, _getter, _idify
File "/usr/lib/python2.7/site-packages/nitrate/nitrate/base.py", line 426, in
from nitrate.cache import Cache
File "/usr/lib/python2.7/site-packages/nitrate/cache.py", line 121, in
import nitrate.immutable as immutable
File "/usr/lib/python2.7/site-packages/nitrate/nitrate/immutable.py", line 1341, in
from nitrate.mutable import TestCase, CaseRun
File "/usr/lib/python2.7/site-packages/nitrate/mutable.py", line 1473, in
from nitrate.containers import (CaseBugs, CaseComponents, CasePlans,
File "/usr/lib/python2.7/site-packages/nitrate/nitrate/containers.py", line 71, in
from nitrate.immutable import Component, Bug, Tag
ImportError: cannot import name Component

ColoredFormatter can't handle unicode

When tcms-results tries to log info about bugs it processes, it tracebacks like this:

Traceback (most recent call last):
File "/usr/lib64/python2.7/logging/init.py", line 851, in emit
msg = self.format(record)
File "/usr/lib64/python2.7/logging/init.py", line 724, in format
return fmt.format(record)
File "/usr/lib/python2.7/site-packages/nitrate/config.py", line 166, in format
return u"{0} {1}".format(level, record.getMessage())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 120: ordinal not in range(128)

traceback when Jira ticket is linked to a TestCase

The code expects only bugzilla bugs are linked to TCs. If there is a Jira issue with ID FOO-123 linked, python-nitrate tracebacks

list(nitrate.TestCase(12345).bugs)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 155, in __len__
    return len(self._items)
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 105, in _items
    self._fetch()
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 411, in _fetch
    self._current = set([Bug(inject) for inject in injects])
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 411, in <listcomp>
    self._current = set([Bug(inject) for inject in injects])
  File "/usr/lib/python3.6/site-packages/nitrate/immutable.py", line 1191, in __init__
    self._fetch(inject)
  File "/usr/lib/python3.6/site-packages/nitrate/immutable.py", line 1237, in _fetch
    self._bug = int(inject["bug_id"])
ValueError: invalid literal for int() with base 10: 'FOO-123'

traceback when Jira ticket is linked to a TestCase

The code expects only bugzilla bugs are linked to TCs. If there is a Jira issue with ID FOO-123 linked, python-nitrate tracebacks

list(nitrate.TestCase(12345).bugs)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 155, in __len__
    return len(self._items)
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 105, in _items
    self._fetch()
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 411, in _fetch
    self._current = set([Bug(inject) for inject in injects])
  File "/usr/lib/python3.6/site-packages/nitrate/containers.py", line 411, in <listcomp>
    self._current = set([Bug(inject) for inject in injects])
  File "/usr/lib/python3.6/site-packages/nitrate/immutable.py", line 1191, in __init__
    self._fetch(inject)
  File "/usr/lib/python3.6/site-packages/nitrate/immutable.py", line 1237, in _fetch
    self._bug = int(inject["bug_id"])
ValueError: invalid literal for int() with base 10: 'FOO-123'

float as a prarameter of listed() function

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/nitrate/cache.py", line 400, in exit
    self.save()
  File "/usr/lib/python3.6/site-packages/nitrate/cache.py", line 259, in save
    log.cache("Cache dump stats:\n" + self.stats().strip())
  File "/usr/lib/python3.6/site-packages/nitrate/cache.py", line 520, in stats
    human(current_class._expiration))
  File "/usr/lib/python3.6/site-packages/nitrate/utils.py", line 151, in human
    for period in ["year", "month", "day", "hour", "minute", "second"]
  File "/usr/lib/python3.6/site-packages/nitrate/utils.py", line 153, in <listcomp>
    or time.seconds == time.days == 0 and period == "second"])
  File "/usr/lib/python3.6/site-packages/nitrate/utils.py", line 56, in listed
    items = list(items)
TypeError: 'float' object is not iterable

Crashes in utils.py, line 56 when items is type of float:

# Convert items to list if necessary
if isinstance(items, int):
    items = range(items)
elif not isinstance(items, list):
    items = list(items)

The float maybe came from:

def human(time):
    """ Convert timedelta into a human readable format """
    count = {}
    count["year"] = time.days / 365
    count["month"] = (time.days - 365 * count["year"]) / 30
    count["day"] = 0 if count["year"] > 0 else time.days % 30
    count["hour"] = time.seconds / 3600
    count["minute"] = (time.seconds - 3600 * count["hour"]) / 60
    count["second"] = (
            time.seconds - 3600 * count["hour"] - 60 * count["minute"])
    return listed([
            listed(count[period], period)
            for period in ["year", "month", "day", "hour", "minute", "second"]
            if count[period] > 0
            or time.seconds == time.days == 0 and period == "second"])
  • listed() behaves the same in python2 and python3
  • human() needs to be investigated
  • It happens only when cashing is on

username/password auth got broken

I have nitrate in VM, using user/pass auth. With python2-nitrate-1.4-1 it works, with 1.5 version it doesn't.

url = http://192.168.122.83/xmlrpc/
username = test_user
password = 123456
from nitrate  import User
>>> User().id
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 393, in do_command
    return getattr(self.server, verb)(*params)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 125, in single_request_with_cookies
    return self.parse_response(response)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1342, in parse_response
    return u.close()
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 656, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 400: ['login() takes exactly 2 arguments (48 given)\nTraceback (most recent call last):\n  File "/root/Nitrate/tcms/xmlrpc/filters.py", line 97, in _decorator\n    return func(*args, **kwargs)\n  File "/root/Nitrate/tcms/xmlrpc/decorators.py", line 64, in _new_function\n    return function(request, *args, **kwargs)\nTypeError: login() takes exactly 2 arguments (48 given)\n']>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/nitrate/base.py", line 65, in getter
    self._fetch()
  File "/usr/lib/python3.7/site-packages/nitrate/immutable.py", line 873, in _fetch
    inject = self._server.User.get_me()
  File "/usr/lib/python3.7/site-packages/nitrate/base.py", line 202, in _server
    Config().nitrate.url).server
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 244, in __init__
    password = password,
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 395, in do_command
    raise NitrateXmlrpcError(verb, params, e)
nitrate.xmlrpc_driver.NitrateXmlrpcError: Error while executing cmd 'Auth.login({'username': 'test_user', 'password': 'redhat'})' --> <Fault 400: ['login() takes exactly 2 arguments (48 given)\nTraceback (most recent call last):\n  File "/root/Nitrate/tcms/xmlrpc/filters.py", line 97, in _decorator\n    return func(*args, **kwargs)\n  File "/root/Nitrate/tcms/xmlrpc/decorators.py", line 64, in _new_function\n    return function(request, *args, **kwargs)\nTypeError: login() takes exactly 2 arguments (48 given)\n']>

DeprecationWarning: The SafeConfigParser class has been renamed

Hi, when running with python3.9 I see following warning:

/usr/lib/python3.9/site-packages/nitrate/config.py:273: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
parser = ConfigParser.SafeConfigParser()

-- Docs: https://docs.pytest.org/en/stable/warnings.html

With missing kerberos: local variable 'h' referenced before assignment

When I am using Kerberos to authenticate but I am missing ticket this misleading exception occurs:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/nitrate/base.py", line 200, in _server
    Config().nitrate.username,
AttributeError: 'Section' object has no attribute 'username'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 105, in single_request_with_cookies
    h = self.send_request(host, handler, request_body, verbose)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1267, in send_request
    connection = self.make_connection(host)
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 185, in make_connection
    chost, self._extra_headers, x509 = self.get_host_info(host)
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 163, in get_host_info
    response = vc.step()
  File "<decorator-gen-15>", line 2, in step
  File "/usr/lib64/python3.7/site-packages/gssapi/_utils.py", line 167, in check_last_err
    return func(self, *args, **kwargs)
  File "<decorator-gen-5>", line 2, in step
  File "/usr/lib64/python3.7/site-packages/gssapi/_utils.py", line 127, in catch_and_return_token
    return func(self, *args, **kwargs)
  File "/usr/lib64/python3.7/site-packages/gssapi/sec_contexts.py", line 521, in step
    return self._initiator_step(token=token)
  File "/usr/lib64/python3.7/site-packages/gssapi/sec_contexts.py", line 542, in _initiator_step
    token)
  File "gssapi/raw/sec_contexts.pyx", line 244, in gssapi.raw.sec_contexts.init_sec_context
gssapi.raw.misc.GSSError: Major (851968): Unspecified GSS failure.  Minor code may provide more information, Minor (2529639053): No Kerberos credentials available (default cache: KCM:)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/nitrate/base.py", line 206, in _server
    Config().nitrate.url).server
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 443, in __init__
    login_dict = self.do_command("Auth.login_krbv", [])
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 393, in do_command
    return getattr(self.server, verb)(*params)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/usr/lib64/python3.7/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.7/site-packages/nitrate/xmlrpc_driver.py", line 137, in single_request_with_cookies
    h.close()
UnboundLocalError: local variable 'h' referenced before assignment

Easy way to reproduce (klist is empty)

import nitrate
nitrate.User()._server.User.get_me()

Way to skip ssl verification

Wrong to do but sometimes really necessary to skip verification.
Needs to be configurable by config and runtime (to make --insecure work from python-nitrate consumers without necessity to update the config).

Several fields are incorrect when testcase is initialized from search

Seems that fields (e.g. setup) which are not returned by TestCase.filter xmlrpc call are set to None but should be made 'unknown/unfetched' instead.

Compare output of

> import nitrate
> testcases = list(nitrate.TestCase.search(script='SOME_SCRIPT'))
> for tc in testcases:
      print(tc.setup)
None
None

With asking explicitly for fetch:

> for tc in testcases:
      tc._fetch()      
      print(tc.setup)
<p> Test </p>
<p> Test </p>

When TestCase is initialized via case_id then all fields work correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.