Bug 1032259 - nitrate.TestCase(**hash) doesn't respect 'arguments '
Summary: nitrate.TestCase(**hash) doesn't respect 'arguments '
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-nitrate
Version: rawhide
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Petr Šplíchal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-19 20:25 UTC by Lukáš Zachar
Modified: 2016-06-01 01:45 UTC (History)
3 users (show)

Fixed In Version: python-nitrate-1.0-0.fc20
Clone Of:
Environment:
Last Closed: 2014-05-18 22:53:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
reproducer_2 (3.62 KB, text/plain)
2014-03-10 08:33 UTC, Lukáš Zachar
no flags Details

Description Lukáš Zachar 2013-11-19 20:25:26 UTC
Created attachment 826286 [details]
reproducer.py

Description of problem:

It is not possible to create nitrate.TestCase from hash, which has set arguments. 


Version-Release number of selected component (if applicable):
python-nitrate-0.10-0.el7.noarch from http://psss.fedorapeople.org/python-nitrate/testing/download/

How reproducible:
always

Steps to Reproduce:
1. DEBUG=2 python reproducer.py
2.
3.

Actual results:
None
Traceback (most recent call last):
  File "reproducer.py", line 8, in <module>
    assert nc.arguments == 'PHASE="Perl"'
AssertionError

Expected results:
'PHASE="Perl"'

Additional info:

Tested against http://tcms-test.usersys.redhat.com/xmlrpc/
Whole DEBUG=2 output :

 DEBUG  Coloring enabled
 DEBUG  Caching on level 2
 WARN  Persistent caching off (cache filename not found in the config)
 INFO  Fetching user UID#3020
 DEBUG  Contacting server http://tcms-test.usersys.redhat.com/xmlrpc/
 DEBUG  Initializing user UID#3020
 INFO  Creating a new test case
 DEBUG  Initializing test case TC#0101427
 DEBUG  Initializing CaseTags for TC#0101427 from the inset
 DEBUG  []
 INFO  Successfully created TC#0101427 - Perl
None
Traceback (most recent call last):
  File "reproducer.py", line 8, in <module>
    assert nc.arguments == 'PHASE="Perl"'
AssertionError

Comment 1 Petr Šplíchal 2014-03-03 13:36:04 UTC
You can initialize any python-nitrate object using the "inject"
(short for initial object dict). If you adhere to the format which
is sent by the server in xmlrpc calls I guess you should achieve
what you are looking for:

    #!/usr/bin/python
    
    import nitrate
    
    inject = {'alias': None,
        'arguments': 'X=3',
        'attachment': [],
        'author': 'shillman',
        'author_id': 1472,
        'case_id': 1234,
        'case_status': 'CONFIRMED',
        'case_status_id': 2,
        'category': '--default--',
        'category_id': 1,
        'component': [],
        'create_date': '2008-02-25 15:15:55',
        'default_tester': 'user',
        'default_tester_id': 1791,
        'estimated_time': '00:00:30',
        'extra_link': None,
        'is_automated': 0,
        'is_automated_proposed': False,
        'notes': None,
        'plan': [155],
        'priority': 'P1',
        'priority_id': 1,
        'requirement': None,
        'reviewer': None,
        'reviewer_id': None,
        'script': None,
        'summary': 'Thunderbird: Writing new mail',
        'tag': [],
        }
    
    case = nitrate.TestCase(inject)
    print case.arguments

This seems to work just fine:

    $ COLOR=0 CACHE=0 DEBUG=2 python inject.py 
    [DEBUG] Coloring disabled
    [DEBUG] Caching on level 0
    [DEBUG] Initializing test case TC#0001234
    [DEBUG] Initializing CaseTags for TC#0001234 from the inset
    [DEBUG] []
    X=3

Does that resolve your use case?

Comment 2 Lukáš Zachar 2014-03-07 12:34:51 UTC
Hi Petr,

Your example doesn't work for python-nitrate-0.9-0.

$ CACHE=0 DEBUG=2 python r.py 
[DEBUG] Caching on level 0
[DEBUG] Coloring enabled
Traceback (most recent call last):
  File "r.py", line 32, in <module>
    case = nitrate.TestCase(inject)
  File "/usr/lib/python2.7/site-packages/nitrate/api.py", line 3133, in __init__
    Mutable.__init__(self, id, prefix="TC")
  File "/usr/lib/python2.7/site-packages/nitrate/api.py", line 1564, in __init__
    Nitrate.__init__(self, id, prefix)
  File "/usr/lib/python2.7/site-packages/nitrate/api.py", line 479, in __init__
    self._id = int(id)
TypeError: int() argument must be a string or a number, not 'dict'

Comment 3 Petr Šplíchal 2014-03-07 22:46:26 UTC
Please, test with the latest packages from the testing repo:
http://psss.fedorapeople.org/python-nitrate/testing/download/

Comment 4 Petr Šplíchal 2014-03-08 07:09:30 UTC
Consistent use of the inject was implemented as part of the:

> The Big Cleanup of Ininitialization and Caching
> 
> Initialization check now handled in _is_initialized()
> Cache indexing performed in common _index() method
> Better string representation for incomplete objects
> Consistent use of inject (initial object dictionary)
> Fixed sleep/wake functionality for containers caching
> Simplified _fetch() with injects and use of _index()
> Many unit tests adjusted and improved for caching

https://github.com/psss/python-nitrate/commit/0ff3145

Marking as MODIFIED, move back to ASSIGNED if it does not work as
you would expect. Thanks.

Comment 5 Lukáš Zachar 2014-03-10 08:31:25 UTC
Hi, Sorry for the noise before. I've run it now with python-nitrate-0.11-0.el7.

My use case is about creating new test case with as much attributes as possible in the constructor call (so I don't need to set them later in cycle).

The 'arguments' field is still not set. Also the 'requirement'.

Comment 6 Lukáš Zachar 2014-03-10 08:33:18 UTC
Created attachment 872597 [details]
reproducer_2

New reproducer, which tries to set almost all fields accepted by TestCase.create call.

Comment 7 Lukáš Zachar 2014-03-10 08:39:49 UTC
Output of the reproducer follows. 
There is some inconsistency between tcms and python-nitrate field names which IMHO should be kept as it is now (default_tester, estimated_time, extra_link, is_*)
Container-like bug, plan, tag are expected to be different IMHO too.
However fields setup/effect/breakdown/action are missing completely (RFE bug maybe?)

$ python reproducer.py
action ( do something ) --> !! AttributeError !!
arguments ( THIS="is argument ) --> None
breakdown ( in case of emergency break the glass ) --> !! AttributeError !!
bug ( 1,2,3 ) --> !! AttributeError !!
case_status ( CONFIRMED ) --> !! AttributeError !!
category ( Sanity ) --> Sanity
default_tester ( lzachar ) --> !! AttributeError !!
effect ( something will happen ) --> !! AttributeError !!
estimated_time ( 00:00:01 ) --> !! AttributeError !!
extra_link ( http://localhost ) --> !! AttributeError !!
is_automated ( 1 ) --> !! AttributeError !!
is_automated_proposed ( 1 ) --> !! AttributeError !!
plan ( [10769] ) --> !! AttributeError !!
priority ( P2 ) --> P2
product ( RHEL Tests ) --> <class 'nitrate.api.NitrateNone'>
requirement ( requirement1 and 2 ) --> 
script ( /nonexistent/script/path/ ) --> /nonexistent/script/path/
setup ( build a plane ) --> !! AttributeError !!
summary ( some summary text ) --> some summary text
tag ( tag1,tag2 ) --> !! AttributeError !!
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*
arguments --> None
author --> Lukas Zachar
automated --> True
autoproposed --> False
bugs --> 
category --> Sanity
components --> [None]
created --> 2014-03-10 16:33:37
id --> 304481
identifier --> TC#0304481
link --> 
manual --> False
notes --> 
priority --> P2
product --> <class 'nitrate.api.NitrateNone'>
requirement --> 
script --> /nonexistent/script/path/
status --> PROPOSED
summary --> some summary text
synopsis --> TC#0304481 - some summary text (Sanity, P2, PROPOSED, 0 test plans)
tags --> 
tester --> None
testplans --> [None]
time --> 00:00:00

Comment 8 Petr Šplíchal 2014-03-21 07:36:47 UTC
I see, thanks for clarifying. I've fixed both "arguments" and
"requirement" (by mistake omitted from the _create() method).

    https://github.com/psss/python-nitrate/commit/1c83e07

Regarding the setup/effect/breakdown/action fields: This is for a
separate RFE, low priority for now as it seems these fields are
not very useful for automated processing. Could be in the future.

Comment 9 Fedora Update System 2014-04-11 15:25:30 UTC
python-nitrate-1.0-0.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-nitrate-1.0-0.fc20

Comment 10 Fedora Update System 2014-04-15 15:36:32 UTC
Package python-nitrate-1.0-0.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-nitrate-1.0-0.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-5095/python-nitrate-1.0-0.fc20
then log in and leave karma (feedback).

Comment 11 Fedora Update System 2014-05-18 22:53:47 UTC
python-nitrate-1.0-0.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.