-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Refactor projects fixtures #9411
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
Conversation
Hi @tanvimoharir - thanks for this! Your work looks great 👏
|
Thanks @benjaoming , I was working on the test failures. I will resolve them soon and mark this ready for review. |
Hi @benjaoming , I have resolved all the test errors and some test failures. Currently the remaining test failures are mostly around version related test (and some with build as well) I saw that in some tests the expected version for pip project is 0.8 but with my fixtures script its version is latest. Should I be keeping any specific version for projects creation(in fixtures) |
@tanvimoharir I would be happy to give this a review once the tests are working. Your approach seems to be the right one. Please do ping me if you're stuck with something. |
("Sphinx", "https://github.com/sphinx-doc/sphinx"), | ||
("Numpy", "https://github.com/numpy/numpy"), | ||
("Conda", "https://github.com/conda/conda"), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the tests that rely on specific Version objects to exist, we can add a minimal list of dictionaries for each project that has custom versions. Dictionary should contain some sort of minimal fixture data for the extra Version objects to create for the project.
Unfinished example:
projects = [
# ...
("Pip", "https://github.com/pypa/pip", [{"slug": "0.8", "identifier": "2404a34eba4ee9c48cc8bc4055b99a48354f4950"}]),
# ...
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjaoming I tried with name and slug (but not the identifier) and the error changed to 'Project matching query does not exist'. I will try with the exact dictionaries and see. Thanks!
Hi @tanvimoharir 👋 If you can make these changes work for exactly the same set of tests, that's perfect. That makes the change neutral. After this, you have paved the way for everyone to benefit from simpler fixtures, meaning that we can trim/update test fixtures and add better test cases.
True! There are tests checking if a specific build.Version is correct. A version can both pertain a specific build of a git commit or a git tag. The old fixtures contained some specific versions that are important for these particular tests to work. These Version objects need to exist. I trimmed the original JSON to what I think should be necessary to specify for a "minimal" fixture model, which could simply be a dictionary: I ended up with just 2 essential fields: the |
Hi @benjaoming , I have been trying to update the test data according but have some doubts:
And then considering one of the tests which is actually failing Or And then another test which requires LATEST pip: https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/rtd_tests/tests/test_api.py#L73 These queries don't return anything because the Project query is looking for project with slug='pip'. So should I update any of these tests? |
Hi @tanvimoharir ! The |
If you check the above comment with the Django shell, I have only created 1 project object with slug='pip'. However the Version object is getting created automatically with slug='latest'. Maybe I need to explicitly update the version object? |
In your output, I see:
The slug is wrong? |
No. So if I create the Project object with slug="0.8" the tests are failing because they are querying the Projects with slug="pip", however Version objects are getting created automatically so I'm unable to understand how to create a project with slug=pip and version_slug="0.8". I will look into the models carefully, I might be missing something. |
I can see have understood the relation between Projects and Versions well 👍 Great! I was wondering if you can take the current code and instead turn it into an iteration over a dictionary of projects and slugs? I drafted the idea here: #9411 (comment) Comment as to why I think that's necessary: In order to have good fixtures, they should be easy to read and maintain. By encoding them in a combined dictionary, we truly have fixtures as data. But once we start to create all these projects and their versions in a long Python code segment, the maintenance and development highly risks getting "stuck" again -- as it was in the previous situation. P.S. Sorry about not coming back to the previous comment, but I'm glad you managed! |
Sure @benjaoming, I will do that once I get all the tests to pass. |
That's a great approach! |
Hi @benjaoming, There are now 8 failing tests, I have taken care of all the other errors and failures except these. |
@tanvimoharir your timing is most unfortunate :) Today, Tox 4 was released and I'm just in the middle of troubleshooting current build errors. Once #9789 or another similar PR is merged, please merge the |
Hi @benjaoming, yeah apologies for the delay. Sure I will merge the main branch as you said. However, the failures I mentioned are because of failing unit tests. |
@tanvimoharir I think you need to make What you are doing in (also the tests from |
@tanvimoharir you will need to merge in the latest |
Yeah, I did that now. I have also changed the structure of fixtures data to be list of dictionaries as per your comment above. Although I have separated the project list from version list to match what was used in the fixtures json file. |
@@ -0,0 +1,217 @@ | |||
import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this fixture file (even though it was not part of the original change request)
The reason being that this fixture was dependent on projects data but was loaded before the call_command so I changed this. Refer
Note for this PR: After it's merged, we should probably update @tanvimoharir will get back to this PR soon so we can get it wrapped up. You've done a lot of great work here and I don't see any unaddressed feedback. I was just reminded about it after bootstrapping a development environment. |
Hi @benjaoming , I have the update at readthedocs/common#153 |
@tanvimoharir you should pull in the latest |
@tanvimoharir can you run
|
Oh okay, I just ran the pre-commit without updating common's main. Ill do that! |
@tanvimoharir I see that you ran it and fixes were applied - so I'm not sure how it's not working (this particular pre-commit setup doesn't provide output), might be that your local |
I did update my local main branch :( (used git pull) Its just saying 'no files to update' and skipping everything now on my local |
I think the problem is that there are some improperly formatted lines apart from the changes ( I did see some places with '' instead of "" and additional whitespace) I will run the pre-commit on the entire repository(pre-commit run --all-files), will that be okay? @benjaoming |
@tanvimoharir yup, it can be very disruptive to lint the entire repo. If pre-commit changes files, you should only commit the ones that are already part if this PR. |
Are you suggesting that I lint the entire repo but only commit the files which are relevant to this PR's changes? |
that might work, depending on the amount of changes. |
You can also pull in the changes from #9893 and then you'll see what exactly the problem is... |
@tanvimoharir you can run this command |
@tanvimoharir I might be facing a similar issue now because I'm also running a fork of readthedocs.org. The problem might be that the All of this is unrelated to this PR. Simply push the latest upstream |
Hi @benjaoming , I updated my fork and executed |
Sorry, I didn't notice what was going on here. Your PR branch is called Would you be able to fork your current Here is a draft of what I mean but please adjust to your needs...
|
Refers #9332