Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(flask): backend flask server tests #56

Merged
merged 17 commits into from
Oct 30, 2023
Merged

Conversation

MyStackOverflows
Copy link
Contributor

initial flask server tests, will add more as more functionality is added to the server and/or functionality is changed but these should cover it for now

signed off: Paul Unger piunger@hotmail.com

@MyStackOverflows MyStackOverflows added test Unit/Integration tests area/back-end Back-end work labels Oct 29, 2023
@MyStackOverflows MyStackOverflows linked an issue Oct 29, 2023 that may be closed by this pull request
@MyStackOverflows
Copy link
Contributor Author

note: the 1.mp4 file is not a mistake, it is a necessary file for the tests and shouldn't be deleted, it's used to make sure get_frames() is reading all the correct information

@MyStackOverflows MyStackOverflows marked this pull request as ready for review October 30, 2023 00:16
@MyStackOverflows MyStackOverflows self-assigned this Oct 30, 2023
@tthvo tthvo changed the title feat(tests): backend flask server tests test(flask): backend flask server tests Oct 30, 2023
.gitignore Outdated Show resolved Hide resolved
Copy link
Contributor

@tthvo tthvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very neat! Tho, to add to #55 (comment), consider there are different test suites (i.e NextJS, unittest, database tests, operator tests, helm tests), I propose:

  • All tests are placed close to their source, following the language, framework conventions.
  • All test files can be created as symlinks in /tests. These are non-functional, just for visibility.
  • Add a run-test.sh script or Makefile in /tests that will run the test suites by cd to their corresponding folder.
    • This allows us to run deps installation (i.e. requirements, npm packages. go mod).

The TA/prof can just go run that script. Wdu think?

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Each line in a gitignore file specifies a pattern. When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):

Ahh looks it this is the issue: https://git-scm.com/docs/gitignore#_pattern_format

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Try this:

diff --git a/.gitignore b/.gitignore
index cacb216..a0f8f45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
-# we need this guy
-!**/resources/*.mp4
 
 # don't commit test and temp video/image files
 *.mp4
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..d3bb9ab
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+!resources/*.mp4

This creates an inner .gitignore which should have precedence over the one in project root.

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

@MyStackOverflows are video processor tests requiring AWS credentials?

@MyStackOverflows
Copy link
Contributor Author

@MyStackOverflows are video processor tests requiring AWS credentials?

Strictly no, as we don't test any AWS functionality (mainly because it's difficult to strictly test an AI's output for good/bad without human intervention). However, I believe the video processor makes a request to get a client when it is first initialized which now that you're mentioning it is probably something that should be changed, the tests should probably be run statically without an instantiated object

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Alright, was just asking because CI in #58 is failing but I set some mocked env vars.

@MyStackOverflows
Copy link
Contributor Author

Alright, was just asking because CI in #58 is failing but I set some mocked env vars.

so should I change the tests to not instantiate the class? None of the actual test code requires AWS credentials but it's still making that request to AWS services when it's instantiated which could potentially throw errors or cause issues down the line

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

As in #58, seems like it does not actual check if the credentials are valid as tests passed with fake credentials. Those are checked on-demand, I believe. So you should be okay with current implementations.

ci(vidserver-test): run video processing server in CI
Copy link
Contributor

@tthvo tthvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a comment above. Tho, i would prefer to have all path covered in tests. However, let's wait till we have a test coverage file to see what we miss in tests.

Paul, can u help research into python test coverage?

@MyStackOverflows
Copy link
Contributor Author

Paul, can u help research into python test coverage?

not right this minute but definitely in the next week or so xD
maybe make an issue for that?

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Yes please! Appreciate that!

@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Any other comments or planned changes for this PR?

@MyStackOverflows
Copy link
Contributor Author

MyStackOverflows commented Oct 30, 2023

Any other comments or planned changes for this PR?

don't think so, just waiting for Linh but not sure if she's seen this PR

@connordoman connordoman self-requested a review October 30, 2023 07:29
@tthvo
Copy link
Contributor

tthvo commented Oct 30, 2023

Alright. I would like to this merged to get the tests in CI. If any other concerns arise, please open a new issue to track.

@tthvo tthvo merged commit d5f616f into develop Oct 30, 2023
1 check passed
@tthvo tthvo deleted the gh-55-flask-server-tests branch November 30, 2023 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/back-end Back-end work test Unit/Integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Test Framework for Flask application
3 participants