File: index.html

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (89 lines) | stat: -rw-r--r-- 3,023 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<html>
  <head>
    <meta charset="UTF-8" />
    <script src="https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"></script>
  </head>
  <body>
    <code id="output"></code>
    <script>
      async function main() {
        output = document.getElementById("output");

        pyodide = await loadPyodide({
          stdout: (x) =>
            (output.innerHTML += x.replace(/\s/, "&nbsp") + "<br />"),
          stderr: (x) =>
            (output.innerHTML += x.replace(/\s/, "&nbsp") + "<br />"),
        });
        await pyodide.loadPackage("micropip");
        await pyodide.runPythonAsync(`
          import micropip
          from pyodide.http import pyfetch

          TEST_FILES = [
            "browser.py",
            "async_testing.py",
            ".env",
            "requirements.txt",
          ]

          for filename in TEST_FILES:
            res = await pyfetch(filename, cache="no-cache");
            # get the name of the file
            with open(filename, "wb") as f:
              f.write(await res.bytes())

          with open("requirements.txt") as f:
            # filter comments out
            requirements = [r for r in f.read().split("\\n") if not r.startswith("#") and r]
            await micropip.install(requirements)

          from dotenv import load_dotenv
          from types import ModuleType
          import sys
          import os

          load_dotenv()  # Load environment variables

          TEXT_ANALYTICS_KEY = os.getenv("TEXT_ANALYTICS_KEY")
          TEXT_ANALYTICS_ENDPOINT = os.getenv("TEXT_ANALYTICS_ENDPOINT")
          BLOB_SERVICE_KEY = os.getenv("BLOB_SERVICE_KEY")
          BLOB_SERVICE_ENDPOINT = os.getenv("BLOB_SERVICE_ENDPOINT")

          if not TEXT_ANALYTICS_KEY:
            print("Invalid textanalytics key")
            raise ValueError("Invalid textanalytics key")

          if not TEXT_ANALYTICS_ENDPOINT:
            print("Invalid textanalytics endpoint")
            raise ValueError("Invalid textanalytics endpoint")

          if not BLOB_SERVICE_KEY:
            print("Invalid blob service key")
            raise ValueError("Invalid blob service key")

          if not BLOB_SERVICE_ENDPOINT:
            print("Invalid blob service endpoint")
            raise ValueError("Invalid blob service endpoint")

          # Would have liked to use unittest.mock.patch here, but it doesn't seem
          # to work in Pyodide.

          fake_aiohttp = ModuleType("AioHttp")
          fake_aiohttp.ClientPayloadError = Exception
          sys.modules["aiohttp"] =  fake_aiohttp
          from browser import PyodideTransportIntegrationTestSuite

          test_case = PyodideTransportIntegrationTestSuite(
            text_analytics_endpoint=TEXT_ANALYTICS_ENDPOINT,
            text_analytics_key=TEXT_ANALYTICS_KEY,
            blob_service_key=BLOB_SERVICE_KEY,
            blob_service_endpoint=BLOB_SERVICE_ENDPOINT,
          )
          await test_case.run()
        `);
      }
      main();
    </script>
  </body>
</html>