-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from pietrzakacper/python-reporter
Python reporter
- Loading branch information
Showing
35 changed files
with
854 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { runServer } from "../utils"; | ||
import child_process from "child_process"; | ||
import util from "util"; | ||
import path from "path"; | ||
|
||
const exec = util.promisify(child_process.exec); | ||
|
||
const TOKEN = "test-token"; | ||
const TEST_NAME = "barry"; | ||
|
||
let serverProcess: child_process.ChildProcess; | ||
|
||
test("send hello from Python server", async ({ page }) => { | ||
let serverPort: number; | ||
[serverProcess, serverPort] = await runServer(3500); | ||
|
||
await page.goto(`http://localhost:${serverPort}`); | ||
await page.getByPlaceholder("Enter session ID").fill(TOKEN); | ||
await page.getByRole("button", { name: "Go" }).click(); | ||
|
||
await exec(`./start.sh ${TEST_NAME}`, { | ||
env: { ...process.env, TT_TOKEN: TOKEN, TT_SERVER_URL: `ws://localhost:${serverPort}` }, | ||
cwd: path.join(__dirname, "reporter"), | ||
}); | ||
|
||
await expect(page.getByText(`hello ${TEST_NAME}`)).toBeVisible(); | ||
}); | ||
|
||
test.afterAll(() => { | ||
serverProcess?.kill(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
python3 -m venv .venv | ||
source .venv/bin/activate | ||
pip install -e ../../../../reporters/python | ||
deactivate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import time | ||
import sys | ||
from tracethat import tracethat | ||
|
||
@tracethat | ||
def hello(name: str, greeting='Hello') -> str: | ||
time.sleep(1) | ||
return f'{greeting} {name}' | ||
|
||
def main(): | ||
hello(sys.argv[1]) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
source .venv/bin/activate | ||
python3 main.py $1 | ||
deactivate |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,33 @@ | ||
import { useMemo, useState } from "react"; | ||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "../ui/dropdown-menu"; | ||
import { AvailableLanguage, SHOWN_LANGUAGES, getDisplayData, getSnippet } from "./Snippet.constants"; | ||
import { Button } from "../ui/button/button"; | ||
import { ChevronDown } from "lucide-react"; | ||
import { SHOWN_LANGUAGES, getDisplayData, getInstallationSnippet, getSnippet } from "./Snippet.constants"; | ||
import { HighlightedCode } from "../HighlightedCode"; | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; | ||
|
||
interface SnippetProps { | ||
token: string; | ||
} | ||
export const Snippet = ({ token }: SnippetProps) => { | ||
const [language, setLanguage] = useState<AvailableLanguage>("js"); | ||
const code = useMemo(() => getSnippet(language, token), [language, token]); | ||
|
||
const selectedButton = useMemo(() => { | ||
const { logo, name } = getDisplayData(language); | ||
return ( | ||
<Button variant="outline" size="sm" className="px-1"> | ||
<div className="relative"> | ||
<img src={logo} alt={name} className="h-5 aspect-square rounded-tiny" /> | ||
<div className="fill-absolute ring-1 ring-primary/10 ring-inset rounded-tiny" /> | ||
</div> | ||
<ChevronDown className="ml-1 h-4 w-4" /> | ||
</Button> | ||
); | ||
}, [language]); | ||
|
||
return ( | ||
<div className="relative"> | ||
<div className="absolute top-2 right-2"> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild>{selectedButton}</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
{SHOWN_LANGUAGES.map((lang) => { | ||
const { logo, name } = getDisplayData(lang); | ||
|
||
return ( | ||
<DropdownMenuItem key={lang} onClick={() => setLanguage(lang)}> | ||
<div className="relative"> | ||
<img src={logo} alt={name} className="w-6 aspect-square rounded-tiny" /> | ||
<div className="fill-absolute ring-1 ring-primary/10 ring-inset rounded-tiny" /> | ||
</div> | ||
<span className="ml-2">{name}</span> | ||
</DropdownMenuItem> | ||
); | ||
})} | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</div> | ||
|
||
<HighlightedCode code={code} language={language} /> | ||
</div> | ||
<Tabs defaultValue={SHOWN_LANGUAGES[0]} className="flex flex-col w-full items-end"> | ||
<TabsList> | ||
{SHOWN_LANGUAGES.map((language) => { | ||
const { logo, name } = getDisplayData(language); | ||
return ( | ||
<TabsTrigger key={language} value={language}> | ||
<div className="relative"> | ||
<img src={logo} alt={name} className="w-6 aspect-square rounded-tiny" /> | ||
<div className="fill-absolute ring-1 ring-primary/10 ring-inset rounded-tiny" /> | ||
</div> | ||
</TabsTrigger> | ||
); | ||
})} | ||
</TabsList> | ||
{SHOWN_LANGUAGES.map((language) => ( | ||
<TabsContent key={language} value={language} className="w-full"> | ||
<HighlightedCode language="bash" code={getInstallationSnippet(language)} /> | ||
<br /> | ||
<HighlightedCode language={language} code={getSnippet(language, token)} /> | ||
</TabsContent> | ||
))} | ||
</Tabs> | ||
); | ||
}; |
Oops, something went wrong.