Skip to content

Commit

Permalink
Merge pull request #6 from ritajie/add-pipeline-for-testing
Browse files Browse the repository at this point in the history
Add pipeline about test
  • Loading branch information
ritajie authored Aug 19, 2024
2 parents 9a9ed92 + 10d8f10 commit 434210d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "2.7", "3.6", "3.7", "3.8", "3.9", "3.10" ]
container:
image: registry.jihulab.com/gitlab-cn/mono-client/python${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Test with unittest
run: |
cd requests_to_curl
python test.py
18 changes: 9 additions & 9 deletions requests_to_curl/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def test_post_csv_file(self):
curlified = parse(r.prepare(), return_it=True, print_it=False)
boundary = re.search(r'boundary=(\w+)', curlified).group(1)
expected = (
'curl -X POST'
f' -H \'Content-Type: multipart/form-data; boundary={boundary}\''
' -H \'User-agent: UA\''
f' -d \'--{boundary}\r\nContent-Disposition: form-data; name="file"; filename="data.csv"\r\n\r\n'
'"Id";"Title";"Content"\n'
'1;"Simple Test";"Ici un test d\'"\'"\'échappement de simple quote"\n'
'2;"UTF-8 Test";"ăѣ𝔠ծềſģȟᎥ𝒋ǩľḿꞑȯ𝘱𝑞𝗋𝘴ȶ𝞄𝜈ψ𝒙𝘆𝚣1234567890!@#$%^&*()-_=+;:\'"\'"\'",[]{}<.>/?~𝘈Ḇ𝖢𝕯٤ḞԍНǏ𝙅ƘԸⲘ𝙉০Ρ𝗤Ɍ𝓢ȚЦ𝒱Ѡ𝓧ƳȤѧᖯć𝗱ễ𝑓𝙜Ⴙ𝞲𝑗𝒌ļṃʼnо𝞎𝒒ᵲꜱ𝙩ừ𝗏ŵ𝒙𝒚ź"'
f'\r\n--{boundary}--\r\n\''
' https://httpbin.org/post'
u'curl -X POST'
u' -H \'Content-Type: multipart/form-data; boundary={boundary}\''.format(boundary=boundary) +
u' -H \'User-agent: UA\''
u' -d \'--{boundary}\r\nContent-Disposition: form-data; name="file"; filename="data.csv"\r\n\r\n'.format(boundary=boundary) +
u'"Id";"Title";"Content"\n'
u'1;"Simple Test";"Ici un test d\'"\'"\'échappement de simple quote"\n'
u'2;"UTF-8 Test";"ăѣ𝔠ծềſģȟᎥ𝒋ǩľḿꞑȯ𝘱𝑞𝗋𝘴ȶ𝞄𝜈ψ𝒙𝘆𝚣1234567890!@#$%^&*()-_=+;:\'"\'"\'",[]{}<.>/?~𝘈Ḇ𝖢𝕯٤ḞԍНǏ𝙅ƘԸⲘ𝙉০Ρ𝗤Ɍ𝓢ȚЦ𝒱Ѡ𝓧ƳȤѧᖯć𝗱ễ𝑓𝙜Ⴙ𝞲𝑗𝒌ļṃʼnо𝞎𝒒ᵲꜱ𝙩ừ𝗏ŵ𝒙𝒚ź"' +
u'\r\n--{boundary}--\r\n\''.format(boundary=boundary) +
u' https://httpbin.org/post'
)
self.assertEqual(curlified, expected)

Expand Down

0 comments on commit 434210d

Please sign in to comment.