|
| 1 | +""" |
| 2 | +GitLab API: https://docs.gitlab.com/ce/api/appearance.html |
| 3 | +""" |
| 4 | + |
| 5 | +import pytest |
| 6 | +import responses |
| 7 | + |
| 8 | + |
| 9 | +title = "GitLab Test Instance" |
| 10 | +description = "gitlab-test.example.com" |
| 11 | +new_title = "new-title" |
| 12 | +new_description = "new-description" |
| 13 | + |
| 14 | + |
| 15 | +@pytest.fixture |
| 16 | +def resp_application_appearance(): |
| 17 | + content = { |
| 18 | + "title": title, |
| 19 | + "description": description, |
| 20 | + "logo": "/uploads/-/system/appearance/logo/1/logo.png", |
| 21 | + "header_logo": "/uploads/-/system/appearance/header_logo/1/header.png", |
| 22 | + "favicon": "/uploads/-/system/appearance/favicon/1/favicon.png", |
| 23 | + "new_project_guidelines": "Please read the FAQs for help.", |
| 24 | + "header_message": "", |
| 25 | + "footer_message": "", |
| 26 | + "message_background_color": "#e75e40", |
| 27 | + "message_font_color": "#ffffff", |
| 28 | + "email_header_and_footer_enabled": False, |
| 29 | + } |
| 30 | + |
| 31 | + with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps: |
| 32 | + rsps.add( |
| 33 | + method=responses.GET, |
| 34 | + url="http://localhost/api/v4/application/appearance", |
| 35 | + json=content, |
| 36 | + content_type="application/json", |
| 37 | + status=200, |
| 38 | + ) |
| 39 | + |
| 40 | + updated_content = dict(content) |
| 41 | + updated_content["title"] = new_title |
| 42 | + updated_content["description"] = new_description |
| 43 | + |
| 44 | + rsps.add( |
| 45 | + method=responses.PUT, |
| 46 | + url="http://localhost/api/v4/application/appearance", |
| 47 | + json=updated_content, |
| 48 | + content_type="application/json", |
| 49 | + status=200, |
| 50 | + ) |
| 51 | + yield rsps |
| 52 | + |
| 53 | + |
| 54 | +def test_get_update_appearance(gl, resp_application_appearance): |
| 55 | + appearance = gl.appearance.get() |
| 56 | + assert appearance.title == title |
| 57 | + assert appearance.description == description |
| 58 | + appearance.title = new_title |
| 59 | + appearance.description = new_description |
| 60 | + appearance.save() |
| 61 | + assert appearance.title == new_title |
| 62 | + assert appearance.description == new_description |
| 63 | + |
| 64 | + |
| 65 | +def test_update_appearance(gl, resp_application_appearance): |
| 66 | + resp = gl.appearance.update(title=new_title, description=new_description) |
0 commit comments