Skip to content

Commit

Permalink
ci: Some tests misusing assertTrue for comparisons fix (#7241)
Browse files Browse the repository at this point in the history
* Fix issue avoid-misusing-assert-true found at https://codereview.doctor
  • Loading branch information
code-review-doctor committed Oct 20, 2022
1 parent dcf394b commit 27515cc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cms/tests/test_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,5 @@ def test_context_menus(self):
context['placeholder'] = ph_en
template = Template('{% load cms_tags %}{% render_extra_menu_items placeholder %}')
output = template.render(context)
self.assertTrue(len(output), 200)
self.assertIn('href="/en/admin/cms/page/plugin/alias_plugin/create_alias/"', output)
self.assertIn("Create Alias", output)
2 changes: 1 addition & 1 deletion cms/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def test_create_page_atomic(self):
def test_create_reverse_id_collision(self):
create_page('home', 'nav_playground.html', 'en', published=True, reverse_id="foo")
self.assertRaises(FieldError, create_page, 'foo', 'nav_playground.html', 'en', published=True, reverse_id="foo")
self.assertTrue(Page.objects.count(), 2)
self.assertEqual(Page.objects.count(), 2)

def test_publish_page(self):
page_attrs = self._get_default_create_page_arguments()
Expand Down
2 changes: 1 addition & 1 deletion cms/tests/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def test_republish_multiple_root(self):
other = self.create_page("Another Page", published=True)
child = self.create_page("Child", published=True, parent=home)
child2 = self.create_page("Child", published=True, parent=other)
self.assertTrue(Page.objects.filter(is_home=True).count(), 2)
self.assertEqual(Page.objects.filter(is_home=True).count(), 2)
self.assertTrue(home.is_home)

home = home.reload()
Expand Down
2 changes: 1 addition & 1 deletion cms/tests/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def test_admin_logout_staff(self):
with override_settings(CMS_PERMISSION=True):
with self.login_user_context(self.get_staff()):
response = self.client.get('/en/admin/logout/?%s' % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
self.assertTrue(response.status_code, 200)
self.assertEqual(response.status_code, 200)

def test_show_toolbar_without_edit(self):
page = create_page("toolbar-page", "nav_playground.html", "en",
Expand Down

0 comments on commit 27515cc

Please sign in to comment.