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

Sourcery refactored main branch #3

Merged
merged 1 commit into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions djangobible/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def set_verses(self, verse_ids):
self.verses.all().delete()

# Create new verse relation objects
verse_relations = []
verse_relations = [
VerseRelation(content_object=self, verse=verse_id)
for verse_id in verse_ids
]

for verse_id in verse_ids:
verse_relations.append(VerseRelation(content_object=self, verse=verse_id))
Comment on lines -53 to -56
Copy link
Author

Choose a reason for hiding this comment

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

Function ScriptureIndexedModel.set_verses refactored with the following changes:


VerseRelation.objects.bulk_create(verse_relations)

Expand Down
4 changes: 2 additions & 2 deletions djangobible/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def validate_verse(value: Optional[str]) -> None:

references: List[bible.NormalizedReference] = bible.get_references(value)

if len(references) == 0:
if not references:
Copy link
Author

Choose a reason for hiding this comment

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

Function validate_verse refactored with the following changes:

raise ValidationError("Not a valid reference.")

if len(references) > 1:
raise ValidationError("Only single verse references allowed.")

verse_ids: List[int] = bible.convert_references_to_verse_ids(references)

if len(verse_ids) == 0:
if not verse_ids:
raise ValidationError("Not a valid reference.")

if len(verse_ids) > 1:
Expand Down
4 changes: 2 additions & 2 deletions test_django_app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_objects(test_object_factory):
"Genesis 1:1-4",
]

for i in range(0, 10):
for i in range(10):
Copy link
Author

Choose a reason for hiding this comment

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

Function test_objects refactored with the following changes:

test_object = test_object_factory(f"test object {i + 1}")
test_object.set_verses(
bible.convert_references_to_verse_ids(bible.get_references(references[i]))
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_single_verse_objects(test_single_verse_object_factory):
"Genesis 1:4",
]

for i in range(0, 10):
for i in range(10):
Copy link
Author

Choose a reason for hiding this comment

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

Function test_single_verse_objects refactored with the following changes:

test_single_verse_object = test_single_verse_object_factory(
f"test object {i + 1}"
)
Expand Down