Skip to content

Commit

Permalink
move tests to client
Browse files Browse the repository at this point in the history
  • Loading branch information
phact committed Jun 14, 2024
1 parent 0921537 commit 70567d5
Show file tree
Hide file tree
Showing 45 changed files with 1,286 additions and 789 deletions.
1,198 changes: 1,198 additions & 0 deletions .github/workflows/run-e2e-tests.yml

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import time
from openai import OpenAI
Expand Down
13 changes: 0 additions & 13 deletions client/tests/conftest.py

This file was deleted.

Empty file.
1 change: 1 addition & 0 deletions client/tests/fixtures/duplicate/fake_content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello! This is some fake context for a file upload
Empty file added client/tests/fixtures/fake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/tests/fixtures/fake_content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello! This is some fake context for a file upload
1 change: 1 addition & 0 deletions client/tests/fixtures/same_fake_content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello! This is some fake context for a file upload
83 changes: 83 additions & 0 deletions client/tests/fixtures/sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python
# coding: utf-8

"""
The approach taken is explained below. I decided to do it simply.
Initially I was considering parsing the data into some sort of
structure and then generating an appropriate README. I am still
considering doing it - but for now this should work. The only issue
I see is that it only sorts the entries at the lowest level, and that
the order of the top-level contents do not match the order of the actual
entries.
This could be extended by having nested blocks, sorting them recursively
and flattening the end structure into a list of lines. Revision 2 maybe ^.^.
"""

def sort_blocks():
# First, we load the current README into memory
with open('README.md', 'r') as read_me_file:
read_me = read_me_file.read()

# Separating the 'table of contents' from the contents (blocks)
table_of_contents = ''.join(read_me.split('- - -')[0])
blocks = ''.join(read_me.split('- - -')[1]).split('\n# ')
for i in range(len(blocks)):
if i == 0:
blocks[i] = blocks[i] + '\n'
else:
blocks[i] = '# ' + blocks[i] + '\n'

# Sorting the libraries
inner_blocks = sorted(blocks[0].split('##'))
for i in range(1, len(inner_blocks)):
if inner_blocks[i][0] != '#':
inner_blocks[i] = '##' + inner_blocks[i]
inner_blocks = ''.join(inner_blocks)

# Replacing the non-sorted libraries by the sorted ones and gathering all at the final_README file
blocks[0] = inner_blocks
final_README = table_of_contents + '- - -' + ''.join(blocks)

with open('README.md', 'w+') as sorted_file:
sorted_file.write(final_README)

def main():
# First, we load the current README into memory as an array of lines
with open('README.md', 'r') as read_me_file:
read_me = read_me_file.readlines()

# Then we cluster the lines together as blocks
# Each block represents a collection of lines that should be sorted
# This was done by assuming only links ([...](...)) are meant to be sorted
# Clustering is done by indentation
blocks = []
last_indent = None
for line in read_me:
s_line = line.lstrip()
indent = len(line) - len(s_line)

if any([s_line.startswith(s) for s in ['* [', '- [']]):
if indent == last_indent:
blocks[-1].append(line)
else:
blocks.append([line])
last_indent = indent
else:
blocks.append([line])
last_indent = None

with open('README.md', 'w+') as sorted_file:
# Then all of the blocks are sorted individually
blocks = [
''.join(sorted(block, key=str.lower)) for block in blocks
]
# And the result is written back to README.md
sorted_file.write(''.join(blocks))

# Then we call the sorting method
sort_blocks()


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions client/tests/fixtures/v2/fake_content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello! This is some fake context for a file upload with different content but same name
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 0 additions & 41 deletions client/tests/test_chat_completion.py

This file was deleted.

80 changes: 0 additions & 80 deletions client/tests/test_create_and_stream_run.py

This file was deleted.

32 changes: 0 additions & 32 deletions client/tests/test_embedding.py

This file was deleted.

20 changes: 0 additions & 20 deletions client/tests/test_file_embedding.py

This file was deleted.

Loading

0 comments on commit 70567d5

Please sign in to comment.