1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-15 00:36:11 +01:00
Commit Graph

191 Commits

Author SHA1 Message Date
0c2238435f
Merge pull request #1184 from dirkmueller/cleanups
Cleanups
2022-12-05 09:30:48 +01:00
Dirk Müller
adb1a9b4ef mark boolean and integer_opts as private
It is unused elsewhere, and only used for unit-testing
2022-12-01 10:05:32 +01:00
dc1470a3d7 store: Remove trailing slash from apiurl 2022-11-07 13:57:24 +01:00
4e773cec32 Implement Store class that will replace store_{read,write}* functions 2022-10-25 13:09:29 +02:00
a4720eb776 Add new osc._private module 2022-10-13 10:52:17 +02:00
5094099f08 Disable configparser interpolation to allow unescaped '%' in values 2022-10-04 09:37:33 +02:00
1fe2b17957
Merge pull request #1144 from dmach/1141-search-requests-created-by-myself
Properly handle osc rq -M/--mine option
2022-09-20 13:09:25 +02:00
c8f4487201 Replace core.findpacs() with Package.from_paths() and Package.from_paths_nofail()
The original findpacs() was returning either [Package]
or ([Package], [str]) depending on the `fatal` option.
This confused pylint and it was returning false-positives:
E1101: Instance of 'list' has no '...' member (no-member)
2022-09-20 11:32:25 +02:00
8dbf859ce2 core.Package: add ordering methods, repr and hash 2022-09-20 10:48:01 +02:00
056e6f1dde Improve 'osc rq show' output
* Add 'Created by' field
* Make formatting more consistent across the sections
2022-09-16 12:49:08 +02:00
30d967513e Migrate from get_request_list() to get_request_collection()
The new function uses a new, fast API call.
2022-09-16 12:49:08 +02:00
783ed2b6e0 core.Request - implement ordering compatible with py3 2022-09-16 12:42:09 +02:00
fe59986e1c Run autopep8 to fix whitespace issues 2022-09-12 13:45:19 +02:00
b511be20ff Always import at the toplevel 2022-09-12 13:45:19 +02:00
3296fd8d89 User super() instead of referencing parent classes explicitly 2022-09-12 13:45:19 +02:00
41ceb4b5f8 Remove deprecated 'GnomeKeyringCredentialsManager' and related code 2022-08-25 13:20:25 +02:00
9cc4a5594f Fix resource warnings (unclosed files) 2022-08-24 08:43:09 +02:00
1c581fdf2c Move _get_fixture() to OscTestCase class 2022-08-23 14:28:57 +02:00
00956cf13a Fix conf import in tests/common.py 2022-08-23 14:28:11 +02:00
b306bf0b91 Convert defaults to their expected types
Fixes problems in reading conf values before the configuration
is fully initialized.
2022-08-22 15:08:49 +02:00
8f9cd713de tests: remove comments from oscrc fixtures 2022-08-12 10:06:00 +02:00
feb53212dd Modernize code with pyupgrade
pyupgrade --keep-percent-format --py36-plus `find -name '*.py'`
2022-07-28 19:14:12 +02:00
229913a77f Clean imports up, drop python 2 fallbacks 2022-07-28 13:17:43 +02:00
0d701556f2 Warn when using HTTP connection. Make HTTPS the default.
It is possible to omit protocol in -A/--apiurl now,
because https:// is the default.
2022-07-27 11:15:21 +02:00
93bc0e4731 Switch http_request() to urllib3
Use connection pools for better performance.
Replace M2Crypto with cryptography and urllib3's ssl context.
2022-07-27 11:15:21 +02:00
637cfe8471
Merge pull request #1023 from dmach/fix/622-additional-changes
parseRevisionOption(): Raise an exception on invalid revisons
2022-07-25 18:26:06 +02:00
ca9dc30643 parseRevisionOption(): Raise an exception on invalid revisions 2022-06-02 10:01:57 +02:00
25a6e04e2b Run tests via calling 'setup.py test' 2022-03-29 14:01:55 +02:00
John Vandenberg
090bd0316c OscTestCase: Always reset CWD
Fixes #970
2021-11-07 16:39:39 +08:00
Marcus Huewe
3d21f2498b Merge branch 'tests_python3_fixes' of https://github.com/marcus-h/osc
Make the testsuite work with python3.8
2020-06-04 12:00:14 +02:00
Marcus Huewe
443e3ef90b tests: Ignore the ordering of attributes in XML documents
Old xml.etree.cElementTree versions (python2) reorder the attributes
while recent xml.etree.cElementTree versions (python3) keep the
document order.

Example:

python3:
>>> ET.tostring(ET.fromstring('<foo y="foo" x="bar"/>'))
b'<foo y="foo" x="bar" />'
>>>

python2:
>>> ET.tostring(ET.fromstring('<foo y="foo" x="bar"/>'))
'<foo x="bar" y="foo" />'
>>>

So far, the testsuite compared two serialized XML documents via a simple
string comparison. For instance via,
self.assertEqual(actual_serialized_xml, expected_serialized_xml) where
the expected_serialized_xml is, for instance, a hardcoded str. Obviously,
this would only work for python2 or python3.
In order to support both python versions, we first parse both XML
documents and then compare the corresponding trees (this is OK because
we do not care about comments etc.).

A related issue is the way how the testsuite compares data that is "send"
to the API. So far, this was a plain bytes comparison. Again, this won't
work in case of XML documents (see above). Moreover, we have currently
no notion to "indicate" that the transmitted data is an XML document.
As a workaround, we keep the plain bytes comparison and in case it fails,
we try an xml comparison (see above) as a last resort. Strictly speaking,
this is "wrong" (there might be cases (in the future) where we want to
ensure that the transmitted XML data is bit identical to a fixture file)
but a reasonable comprise for now.

Fixes: #751 ("[python3.8] Testsuite fails")
2020-06-03 21:50:50 +02:00
Marcus Huewe
27ef627f1d Get rid of bytes usage in tests.common
Simply use the .encode() method (encode using the utf-8 encoding).
2020-06-03 21:50:50 +02:00
Marcus Huewe
c0343207ea Make tests.common.MyHTTPHandler.__mock_PUT bytes aware
For now, we assume that if the "exp" keyword argument is specified,
then it is a str. In this case, we simply encode it (using the utf-8
encoding).
Also, simplify the code a bit (get rid of the if-statement that is
always executed).
2020-06-03 21:50:10 +02:00
Adam Williamson
13a13a87c4 Fix ElementTree imports for Python 3.9
Importing `cElementTree` has been deprecated since Python 3.3 -
importing `ElementTree` automatically uses the fastest
implementation available - and is finally removed in Python 3.9.
Importing cElementTree directly (not as part of xml) is an even
older relic, it's for Ye Time Before ElementTree Was Added To
Python and it was instead an external module...which was before
Python 2.5.

We still need to work with Python 2.7 for now, so we use a try/
except to handle both 2.7 and 3.9 cases. Also, let's not repeat
this import 12 times in one file for some reason.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2020-06-02 15:13:10 -07:00
ea5f8d40aa
Make check_for_request_on_action on per default.
Fixes #337
2019-10-10 18:02:20 +02:00
5f1109072f fix checkout of meta files
typo leaded to wrong parameter
2019-09-16 14:01:35 +02:00
lethliel
36ec0c48d4 Remove passx encode/decode functions from conf.py
They are no longer needed with the new CredentialsManagers
2019-08-29 15:06:48 +02:00
lethliel
2b47be6b1e switch to difflib.diff_bytes in python3 case.
The files are now opened as rb for diffing. In python2 nothing changes.
In python3 the returned diff is bytes now.

The following changes were made:
  * commandline.py: The returned diff is now bytes
  * get_diff now returs the diff as a bytes-like object
  * run_pager writes with sys.stdout.buffer.write if message
    is not a string
  * for the commit message the returned diff needs to be decoded
    now. Otherwise it will just producce garbage. For the commit
    message the diff on decoded bytes-objects is ok. (nothing harmfull
    can happen here)
  * fixed submit_action_diff
  * fixed request_interactive_review
2019-07-24 13:48:39 +02:00
Marco Strigl
d5108c7536
Merge pull request #464 from lethliel/python3_utils_helper
[python3] add helper functions for python3 support
2019-04-15 15:00:58 +02:00
lethliel
39ae30bcc2 change to open() with 'rb' to get bytes in python3
With this change you get bytes with python3 and string in python2

disable travis tests for python 3.x until the full python3 branch
is merged. Otherwise the tests will fail and master isn't python3
ready anyways
2018-11-13 15:56:05 +01:00
lethliel
4b29e1c543 add helper functions for python3 support
This functions are used in the whole code and are
mandatory for the python3 support to work. In python2
case nothing is touched.

* cmp_to_key:
  converts a cmp= into a key= function

* decode_list:
  decodes each element of a list. This is needed if
  we have a mixed list with strings and bytes.

* decode_it:
  Takes the input and checks if it is not a string.
  Then it uses chardet to get the encoding.
2018-11-08 09:55:07 +01:00
5e03ffcec9
Add --watch for osc prjresults --xml
Like: osc results --watch
2018-11-06 15:13:08 +01:00
a5e967efb3
Test osc results and prjresults 2018-11-05 23:54:11 +01:00
e1fd0b4ee9 add support for approved requests (requires OBS 2.10) 2018-10-18 13:26:39 +02:00
lethliel
69983249ef cleanup xpath. submit/* is ignored by the API since 2012 2018-08-07 11:53:49 +02:00
lethliel
f0325eb0b5 added code to get the sha256 hashes of files
This is needed for a new validation of the source server.

The source server will 'ask' for the sha256 sum of files which are new or
modified and osc calculates the sha256 sums for those files and sends them
back to the server.

The server checks the sha256 sums and if dies if something is wrong.
2017-11-27 16:18:19 +01:00
Marcus Huewe
6965dc5cd4 Adjust request testcases to the upcoming Request api change
There is no need to compute the request creator, because it is
stored in the request xml. Moreover, the old computation yields
a wrong result (see issue #286).
2017-04-12 12:55:16 +02:00
Marcus Huewe
502dbaa030 tests.common: req.data can also be a file-like object 2016-05-29 16:21:01 +02:00
Marcus Huewe
0de99cadbb - added comment for a change introduced in commit 4d3fcd9dc1 2015-08-13 14:13:08 +02:00
Oleg Girko
4d3fcd9dc1 Fix Python 3 support.
This change fixes errors when running test suite with Python 3.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
2015-08-13 12:44:19 +01:00
a031dbd083 show review comments in an own line. Before they started in the same line, but reached on typical
screens anyway the second line if they had more than a few chars.
2015-08-13 08:07:34 +02:00
7b79298138 - fix test case for showing update link 2015-03-09 09:04:33 +01:00
3d07bd8460 - fix description rendering in history elements 2014-09-11 14:34:22 +02:00
Christian Berendt
d35983d5b8 Resolve PEP8 issue W291
* W291 trailing whitespace
2014-08-12 15:01:16 +02:00
f29a1b6e79 - follow in test suite the old/new setlinkrev behaviour 2014-05-16 11:58:36 +02:00
Marcus Huewe
570e3e5c85 - tests/test_setlinkrev: added two new testcases
Behave correctly if the _link already has a rev attribute.

Also added a fixture file that I forgot in
commit 6b579791a1.
2014-03-03 22:41:51 +01:00
Marcus Huewe
6b579791a1 - tests.test_setlinkrev: adjusted testcases for the new set_link_rev semantics (see #72) 2014-03-03 21:54:59 +01:00
Ludwig Nussel
f065dc4765 show source revision in submit requests 2014-02-27 16:46:49 +01:00
7b3b9ebc0f Fix fixtures for commit 2014-02-27 16:45:44 +01:00
Marcus Huewe
4ef62d0daf - tests.test_commit: added new testcase
Only update storefiles if the commit was successful (see bug #65)
2014-01-09 13:53:41 +01:00
Marcus Huewe
57d9b48dc0 - tests.suite: added TestConf testcase to suite 2014-01-08 15:43:57 +01:00
Michal Vyskocil
111fd87715 passx encode/decode functions
The string.encode('bz2') does not work in python3. Implement
passx_encode/passx_decode functions compatible with python 2.6, 2.7 and
3.3.

Add a simple unit test.
2014-01-08 15:43:57 +01:00
Marcus Huewe
f7eab473f0 - tests.test_prdiff: fixed testcases (got broken by commit bd3a6d2fc8) 2013-11-11 09:15:59 +01:00
Michal Vyskocil
b787ca2b39 python3 compatibility: make all unit test pass
There are many places can't be covered by 2to3, especially the
str/unicode -> str/bytes change done in python3. This is a big patch
incorporating all changes made in order to make python3 suite.py run
without any single failure.

It

 * adapt the introspect_handler_3 for case there are no __defaults__
 * adds the ET_ENCODING variable for ET.fromstring ("unicode" in py3,
  "utf-8" in py2)
 * (re)adds various builtins to both python versions
    - memoryview to python 2.6
    - bytes compatible with py3 to 2.6 and 2.7

and it changes few parts of tests/common.py in order to be compatible
with python3

 * new urlcompare method compares all components or url + parsed query
   string in a dictionary, so the ordering, neither quoting does not matter
 * bytes builtin has been added to 2.x and used in assertEqualMultiline
2013-04-16 10:51:42 +02:00
Michal Vyskocil
f0186dbde8 python3 compatibility: fix all tests 2013-04-16 10:51:42 +02:00
Marcus Huewe
d4b8fbbba4 - tests.test_prdiff: disabled the usage of keyrings when running the cli
Alternatively we could also disable the keyring usage in the config file.
2013-01-24 15:35:11 +01:00
Adam Spiers
57c8cffe66 - add prdiff subcommand and test suite 2013-01-18 22:38:21 +00:00
Adam Spiers
9b1c6f0204 - refactor assertEqualMultiline into common.py for reuse
This will be reused by the tests for the imminent prdiff subcommand.
2013-01-18 22:38:21 +00:00
Marcus Huewe
33f3ab4203 - sigh... make jenkins happy again (finally)
The jenkins build got broken by commit 178120c99e
(python 2.6's re.sub doesn't support a flags argument).
2013-01-18 18:27:50 +01:00
Marcus Huewe
178120c99e - make travis-ci happy again...
It got broken in commit 6a332bc1c6
2013-01-18 18:12:41 +01:00
Marcus Huewe
6a332bc1c6 - tests.test_difffiles: removed "count" argument from re.sub in __canonise_diff
Old python versions don't support "count". This should fix the jenkins build
again.
2013-01-18 17:11:42 +01:00
Marcus Huewe
203a4eeab5 - tests.test_difffiles: added TODO to __canonise_diff. 2013-01-18 16:37:08 +01:00
Adam Spiers
ef0f24c2f6 - avoid false negative failures due to trivial differences in diff hunk headers
When a hunk header refers to a single line in the "from"
  file and/or the "to" file, e.g.

    @@ -37,37 +41,43 @@
    @@ -37,39 +41,41 @@
    @@ -37,37 +41,41 @@

  some systems will avoid repeating the line number:

    @@ -37 +41,43 @@
    @@ -37,39 +41 @@
    @@ -37 +41 @@

  so we need to canonise the output to avoid false negative
  test failures.
2013-01-18 13:44:30 +00:00
Adam Spiers
479f5d5011 - improve output of assertEquals failures on multi-line strings 2013-01-18 13:44:30 +00:00
Marcus Huewe
46b9fd36e4 - tests.common: disable usage of keyring and gnome-keyring in the testsuite
Otherwise it'll lead to (unexpected) errors if python-keyring or gnome-keyring
are installed.
2013-01-18 14:27:28 +01:00
1000c26c6f - fix fixtures for last vrev change 2012-03-02 16:10:36 +01:00
Sascha Peilicke
ca9e38c3d9 Generate JUnit-compatible XML test result reports if 'xmlrunner' is available. 2011-09-08 11:43:45 +02:00
Sascha Peilicke
af86600880 Fix tests/test_request.py, requests seem to have a trainling newline now 2011-08-18 16:02:34 +02:00
dbe99c338f - follow changes during commit in test cases 2011-06-07 16:33:08 +02:00
Marcus Huewe
e247cf358c - adjusted testsuite for the latest setlinkrev changes 2011-03-21 16:53:48 +01:00
Marcus Huewe
e1080aa476 - common.py, __get_response: support "code" keyword argument to specify the http status code 2011-03-21 16:52:13 +01:00
Marcus Huewe
f0eb8946d3 - also test _link without "project" attribute 2011-02-22 17:53:58 +01:00
Marcus Huewe
40928d2460 - added testcases for "set_link_rev" 2011-02-22 17:53:58 +01:00
Marcus Huewe
74594eb9ec - adjusted testcase oscrc's for recent config changes 2011-02-11 12:44:48 +01:00
Marcus Huewe
73ffb036f8 - test_request: test get_actions method 2011-01-29 17:43:36 +01:00
Marcus Huewe
dda670f3de - test_request: adjusted testcase to the latest format changes 2011-01-24 09:34:37 +01:00
Marcus Huewe
6132f89268 - test_deletefiles.py: new testcases for skipped files 2011-01-17 14:59:46 +01:00
Marcus Huewe
e1b1f66bae - TestRequest: added testcase for action element with acceptinfo subelement 2011-01-12 22:20:47 +01:00
Marcus Huewe
8c26c74620 - added testcases for the rewritten Request class 2010-12-30 02:27:15 +01:00
Marcus Huewe
b99a903873 - def setUp: added "copytree" parameter to disable the copy of the "osctest" dir 2010-12-30 01:57:41 +01:00
Marcus Huewe
d77f8919fe - Project.init_project: return Project object
- adjusted testcases
2010-12-23 02:15:58 +01:00
Marcus Huewe
f8eae74898 - added new testcases in order to test the status methods for projects and packages 2010-12-22 23:12:24 +01:00
Marcus Huewe
062bb35c95 - removed unused imports 2010-12-19 20:32:06 +01:00
Marcus Huewe
70e43a87c2 - added testcases for #658664 ("osc: a package internal error occured")
- a file was marked as 'A' but the file didn't exist in the wc:
  - if it's part of the commit abort
  - otherwise ignore it
2010-12-17 23:23:39 +01:00
Marcus Huewe
71bedd4bb1 - new testcases for repair_wc: check if the passed parameter is a valid apiurl 2010-12-09 20:32:07 +01:00
Marcus Huewe
fffd0c395a - added new testcases for #657838 ("osc 0.130: osc repairwc fails totally - working copy useless") 2010-12-07 20:29:59 +01:00
Marcus Huewe
1a0cea8a4d - fixed testsuite 2010-11-30 19:11:05 +01:00
Marcus Huewe
48eaacef18 - new testcase: repairwc: repair a project wc with no apiurl 2010-10-10 21:36:07 +02:00
Marcus Huewe
cda7ffc040 - testcases for "init_project" 2010-10-09 16:25:44 +02:00
Marcus Huewe
c3c75689ef - added testcases for repairwc in order to repair a wc if the "_apiurl" file is missing 2010-09-28 23:01:39 +02:00