Skip to content

Conversation

@stephenchengCloud
Copy link
Collaborator

@stephenchengCloud stephenchengCloud commented Feb 29, 2024

  1. Create a new directory (python3/bin) for python3 scripts and move hfx_filename into it.
  2. Migrate hfx_filename to python3.
  3. Adjust CI check configurations to apply pytype check and unit test coverage to python3 scripts.
  4. Added unit tests and covered all functions in hfx_filename.
  5. Manually tested hfx_filename on XS8 to cover corner cases that not covered by unit tests:
  • Use Flask to fake a HTTP server:
from flask import Flask, request

app = Flask(__name__)

@app.route('/remote_db_access', methods=['POST'])
def handle_request():
    # Extract session_id from query parameters
    session_id = request.args.get('session_id')

    # Extract data from the request XML
    data = "hotfix_filename"

    # Generate the response body with the desired format
    prefix = "<value><array><data><value>success</value><value>"
    suffix = "</value></data></array></value>"
    response_body = f"{prefix}{data}{suffix}"

    # Set the appropriate Content-Type header for XML response
    headers = {'Content-Type': 'application/xml'}

    return response_body, 200, headers

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080)
  • Scenario 1: Normal process
    image
  • Scenario 2: Response body in None
    image
  • Scenario 3: Response prefix is wrong
    image
  • Scenario 4: Response suffix is wrong
    image

… BIN

Signed-off-by: Stephen Cheng <stephen.cheng@cloud.com>
Signed-off-by: Stephen Cheng <stephen.cheng@cloud.com>
@codecov
Copy link

codecov bot commented Feb 29, 2024

Codecov Report

Merging #5480 (aec50b0) into feature/py3 (a31e212) will increase coverage by 2.2%.
The diff coverage is 96.5%.

Additional details and impacted files
@@              Coverage Diff              @@
##           feature/py3   #5480     +/-   ##
=============================================
+ Coverage         49.0%   51.2%   +2.2%     
=============================================
  Files               18      21      +3     
  Lines             2319    2451    +132     
=============================================
+ Hits              1138    1257    +119     
- Misses            1181    1194     +13     
Files Coverage Δ
python3/unittest/import_file.py 100.0% <100.0%> (ø)
python3/unittest/test_hfx_filename.py 100.0% <100.0%> (ø)
python3/bin/hfx_filename 77.1% <76.9%> (ø)
Flag Coverage Δ
python2.7 53.3% <ø> (ø)
python3.11 57.9% <96.5%> (+2.0%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@psafont psafont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks!

@liulinC liulinC merged commit 5ba31f5 into xapi-project:feature/py3 Mar 1, 2024
@github-actions
Copy link

github-actions bot commented Mar 1, 2024

pytype_reporter extracted 40 problem reports from pytype output

.

You can check the results of the job here

@stephenchengCloud stephenchengCloud deleted the private/stephenche/CP-47935 branch July 31, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants