Skip to content

Refactor projects fixtures #9926

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

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2391489
Adding command file with basic code
tanvimoharir Jul 1, 2022
ab1eee8
Changes
tanvimoharir Jul 7, 2022
586b5d5
Reverting unrequired formatting
tanvimoharir Jul 7, 2022
7d52ae2
Precommit changes
tanvimoharir Jul 7, 2022
32cf796
Updating fixtures use in all rtd tests
tanvimoharir Jul 18, 2022
94c1c23
Merge branch 'readthedocs:main' into main
tanvimoharir Aug 27, 2022
a213d3b
Updating more tests using older fixture
tanvimoharir Aug 31, 2022
8fc0a95
Resolving django integrity error
tanvimoharir Sep 1, 2022
15573d0
Updating setup for APITests
tanvimoharir Sep 2, 2022
dba2d69
Merge branch 'readthedocs:main' into main
tanvimoharir Sep 29, 2022
87bdbd6
Reverting ApiVersionTest setup
tanvimoharir Sep 30, 2022
b9b001b
Resolving some test erors, reverting some changes
tanvimoharir Oct 27, 2022
203cd32
Fixing static id asserts in test_project.py
tanvimoharir Oct 28, 2022
e2cdac4
Fixing version compare tests
tanvimoharir Oct 31, 2022
630c87f
Fixing pip version compare test
tanvimoharir Nov 4, 2022
a28eea7
Fixing api and footer tests
tanvimoharir Nov 8, 2022
58a7ed8
Reverting the unintended newline removal change
tanvimoharir Dec 8, 2022
8d3fb89
Fixing tests for views and projects
tanvimoharir Dec 12, 2022
34ef3ff
Changing fixture data to be list of dictionaries
tanvimoharir Dec 12, 2022
e9bfd24
Merge branch 'readthedocs:main' into main
tanvimoharir Dec 12, 2022
9580256
Merge branch 'readthedocs:main' into main
tanvimoharir Jan 13, 2023
d83808e
Running through pre-commit
tanvimoharir Jan 13, 2023
8418f42
Merge branch 'readthedocs:main' into main
tanvimoharir Jan 20, 2023
4be35dc
Merge branch 'readthedocs:main' into main
tanvimoharir Jan 23, 2023
826303c
Precommit updates
tanvimoharir Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,161 changes: 0 additions & 1,161 deletions readthedocs/projects/fixtures/test_data.json

This file was deleted.

255 changes: 255 additions & 0 deletions readthedocs/projects/management/commands/fixtures_projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
"""
Fixture Projects.

This command intends to replace the fixtures file
which is used and instead create projects directly.

"""

from django.core.management.base import BaseCommand

from readthedocs.builds.models import Version
from readthedocs.projects.models import Project, ProjectRelationship


class Command(BaseCommand):

help = __doc__

def load_data(self):
projects = [
{
"name": "Read The Docs",
"slug": "read-the-docs",
"repo": "https://github.com/rtfd/readthedocs.org",
"repo_type": "git",
},
{
"name": "Django Test Utils",
"slug": "django-test-utils",
"repo": "https://github.com/ericholscher/django-test-utils",
"repo_type": "git",
},
{
"name": "Fabric",
"slug": "fabric",
"repo": "https://github.com/fabric/fabric",
"repo_type": "git",
},
{
"name": "South",
"slug": "south",
"repo": "https://github.com/dmishe/django-south",
"repo_type": "git",
},
{
"name": "Pip",
"slug": "pip",
"repo": "https://github.com/pypa/pip",
"repo_type": "git",
},
{
"name": "Kong",
"slug": "kong",
"repo": "https://github.com/ericholscher/django-kong",
"repo_type": "git",
},
{
"name": "Djangoembed",
"slug": "djangoembed",
"repo": "https://github.com/worldcompany/djangoembed",
"repo_type": "git",
},
{
"name": "Tastypie",
"slug": "tastypie",
"repo": "https://github.com/codysoyland/django-tastypie",
"repo_type": "git",
},
{
"name": "Django Uni Form",
"slug": "django-uni-form",
"repo": "https://github.com/pydanny/django-uni-form",
"repo_type": "git",
},
{
"name": "Cue",
"slug": "cue",
"repo": "https://github.com/coleifer/cue.git",
"repo_type": "git",
},
{
"name": "Pinax",
"slug": "pinax",
"repo": "https://github.com/pinax/pinax",
"repo_type": "git",
},
{
"name": "Haystack",
"slug": "haystack",
"repo": "https://github.com/toastdriven/django-haystack",
"repo_type": "git",
},
{
"name": "Taggit",
"slug": "taggit",
"repo": "https://github.com/alex/django-taggit",
"repo_type": "git",
},
{
"name": "test_project",
"slug": "test_project",
"repo": "https://github.com/bogususer/non-existing-repo",
"repo_type": "git",
},
{
"name": "Sphinx",
"slug": "sphinx",
"repo": "https://github.com/sphinx-doc/sphinx",
"repo_type": "git",
},
{
"name": "Numpy",
"slug": "numpy",
"repo": "https://github.com/numpy/numpy",
"repo_type": "git",
},
{
"name": "Conda",
"slug": "conda",
"repo": "https://github.com/conda/conda",
"repo_type": "git",
},
]

for project in projects:
Project.objects.get_or_create(**project)

# Clear Version table since it gets populated with all "latest" slugs
# Create specific Version objects matching the original fixtures test data
Version.objects.all().delete()
assert Version.objects.count() == 0
# Create ProjectRelationship object
parent = Project.objects.get(slug="pip")
child = Project.objects.get(slug="test_project")

ProjectRelationship.objects.get_or_create(
parent=parent, child=child, alias=None
)

# Create only specific Version objects for projects readthedocs, pip, Sphinx, Numpy, Conda
# Specific versions same as fixtures
rtd = Project.objects.get(slug="read-the-docs")
pip = Project.objects.get(slug="pip")
sphinx = Project.objects.get(slug="sphinx")
numpy = Project.objects.get(slug="numpy")
conda = Project.objects.get(slug="conda")
versions = [
{
"project": rtd,
"type": "unknown",
"identifier": "2ff3d36340fa4d3d39424e8464864ca37c5f191c",
"verbose_name": "0.2.1",
"slug": "0.2.1",
"supported": True,
"active": True,
"built": True,
},
{
"project": rtd,
"type": "unknown",
"identifier": "354456a7dba2a75888e2fe91f6d921e5fe492bcd",
"verbose_name": "0.2.2",
"slug": "0.2.2",
"supported": True,
"active": True,
"built": True,
},
{
"project": rtd,
"type": "unknown",
"identifier": "master",
"verbose_name": "latest",
"slug": "latest",
"supported": True,
"active": True,
"built": True,
},
{
"project": rtd,
"type": "unknown",
"identifier": "not_ok",
"verbose_name": "not_ok",
"slug": "not_ok",
"supported": True,
"active": False,
"built": True,
},
{
"project": rtd,
"type": "unknown",
"identifier": "awesome",
"verbose_name": "awesome",
"slug": "awesome",
"supported": True,
"active": True,
"built": True,
},
{
"project": pip,
"type": "tag",
"identifier": "2404a34eba4ee9c48cc8bc4055b99a48354f4950",
"verbose_name": "0.8",
"slug": "0.8",
"supported": False,
"active": True,
"built": False,
},
{
"project": pip,
"type": "tag",
"identifier": "f55c28e560c92cafb6e6451f8084232b6d717603",
"verbose_name": "0.8.1",
"slug": "0.8.1",
"supported": False,
"active": True,
"built": False,
},
{
"project": sphinx,
"type": "branch",
"identifier": "master",
"verbose_name": "latest",
"slug": "latest",
"supported": True,
"active": True,
"built": False,
},
{
"project": numpy,
"type": "branch",
"identifier": "master",
"verbose_name": "latest",
"slug": "latest",
"supported": True,
"active": True,
"built": False,
},
{
"project": conda,
"type": "branch",
"identifier": "master",
"verbose_name": "latest",
"slug": "latest",
"supported": True,
"active": True,
"built": False,
},
]

for version in versions:
Version.objects.get_or_create(**version)

def handle(self, *args, **kwargs):
self.load_data()
self.stdout.write("Loaded data")
Loading