-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move coverage view to management command
- Loading branch information
1 parent
905ab74
commit ca004a9
Showing
11 changed files
with
163 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from django.apps import apps | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.utils.termcolors import make_style | ||
|
||
from linkcheck.utils import get_coverage_data, get_suggested_linklist_config | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
cyan = staticmethod(make_style(fg='cyan')) | ||
|
||
help = 'Go through all models and check whether they are registered with linkcheck' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
'--model', | ||
help="Generate the suggested config for this model", | ||
) | ||
|
||
def handle(self, *args, model, **options): | ||
if model: | ||
try: | ||
model_class = apps.get_model(model) | ||
except Exception as e: | ||
raise CommandError( | ||
f'Model "{model}" does not exist.' | ||
) from e | ||
self.stdout.write(get_suggested_linklist_config(model_class)) | ||
else: | ||
covered, uncovered = get_coverage_data() | ||
self.stdout.write('All covered models:\n') | ||
self.stdout.write(', '.join(map(self.cyan, covered))) | ||
for model, suggested_config in uncovered: | ||
self.stdout.write(f'\nSuggested config for model {model}:') | ||
self.stdout.write(self.cyan(suggested_config)) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.