Coverage for api/examples/audio_requests.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 06:14 +0000

1from api.examples.environment import ORIGIN, TOKEN 

2 

3 

4auth = f'-H "Authorization: Bearer {TOKEN}"' if TOKEN else "" 

5identifier = "8624ba61-57f1-4f98-8a85-ece206c319cf" 

6 

7syntax_examples = { 

8 "using single query parameter": "test", 

9 "using multiple query parameters": "test&license=pdm,by&categories=illustration&page_size=1&page=1", # noqa: E501 

10 "that is an exact match of Giacomo Puccini": r"%22Giacomo%20Puccini%22", 

11 "related to both dog and cat": "dog+cat", 

12 "related to dog or cat, but not necessarily both": "dog|cat", 

13 "related to dog but won't include results related to 'pug'": "dog -pug", 

14 "matching anything with the prefix 'net'": "net*", 

15 "matching dogs that are either corgis or labrador": "dogs + (corgis | labrador)", 

16 "matching strings close to the term theater " 

17 "with a difference of one character": "theatre~1", 

18} 

19 

20audio_search_list_curl = "\n".join( 

21 f""" 

22# Example {index}: Search for audio {purpose} 

23curl \\ 

24 {auth} \\ 

25 "{ORIGIN}/v1/audio/?q={syntax}" 

26""" 

27 for (index, (purpose, syntax)) in enumerate(syntax_examples.items()) 

28) 

29 

30audio_search_curl = f""" 

31# Search for music titled "Wish You Were Here" by The.madpix.project 

32curl \\ 

33 {auth} \\ 

34 "{ORIGIN}/v1/audio/?title=Wish%20You%20Were%20Here&creator=The.madpix.project" 

35""" 

36 

37audio_stats_curl = f""" 

38# Get the statistics for audio sources 

39curl \\ 

40 {auth} \\ 

41 "{ORIGIN}/v1/audio/stats/" 

42""" 

43 

44audio_detail_curl = f""" 

45# Get the details of audio ID {identifier} 

46curl \\ 

47 {auth} \\ 

48 "{ORIGIN}/v1/audio/{identifier}/" 

49""" 

50 

51audio_related_curl = f""" 

52# Get related audio files for audio ID {identifier} 

53curl \\ 

54 {auth} \\ 

55 "{ORIGIN}/v1/audio/{identifier}/related/" 

56""" 

57 

58audio_complain_curl = f""" 

59# Report an issue about audio ID {identifier} 

60curl \\ 

61 -X POST \\ 

62 -H "Content-Type: application/json" \\ 

63 {auth} \\ 

64 -d '{{"reason": "mature", "description": "This audio contains sensitive content"}}' \\ 

65 "{ORIGIN}/v1/audio/{identifier}/report/" 

66""" 

67 

68audio_waveform_curl = f""" 

69# Get the waveform of audio ID {identifier} 

70curl \\ 

71 {auth} \\ 

72 -H "Content-Type: application/json" \\ 

73 "{ORIGIN}/v1/audio/{identifier}/waveform/" 

74"""