File: test_logo.py

package info (click to toggle)
python-duo-client 5.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 768 kB
  • sloc: python: 7,105; sh: 6; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
from .base import TestAdmin
import os
import base64
import urllib.parse


class TestLogo(TestAdmin):

    def test_update_logo(self):
        # Get an image to upload:
        logo_path = os.path.join(self.TEST_RESOURCES_DIR, "barn-owl-small.png")
        with open(logo_path, "rb") as image_file:
            logo_file = image_file.read()

            # Call function in client:
            response = self.client.update_logo(logo_file)

            # Prep validation text:
            base64_logo = base64.b64encode(logo_file)
            base64_logo = urllib.parse.quote_plus(base64_logo)

            # Validate response:
            self.assertTrue(
                json.loads(response['body']).get('logo'),
                base64_logo
            )