-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove dependency on factory_boy - Add assertRoute for checking routes and redirects - Add add_force_login to simplfy auth checks
- Loading branch information
Showing
10 changed files
with
127 additions
and
171 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,40 +1,29 @@ | ||
# Copyright (c) 2017 LINE Corporation | ||
# These sources are released under the terms of the MIT license: see LICENSE | ||
|
||
from unittest import mock | ||
|
||
import factory.django | ||
from django.contrib.auth.models import User | ||
from django.db.models.signals import post_save, pre_save | ||
from django.test import override_settings | ||
from django.urls import reverse | ||
|
||
from promgen import models | ||
from promgen.tests import PromgenTest | ||
|
||
TEST_SETTINGS = PromgenTest.data_yaml('examples', 'promgen.yml') | ||
TEST_ALERT = PromgenTest.data('examples', 'alertmanager.json') | ||
TEST_IMPORT = PromgenTest.data('examples', 'import.json') | ||
TEST_REPLACE = PromgenTest.data('examples', 'replace.json') | ||
from django.urls import reverse | ||
|
||
|
||
class RouteTests(PromgenTest): | ||
longMessage = True | ||
|
||
@factory.django.mute_signals(pre_save, post_save) | ||
def setUp(self): | ||
self.client.force_login(User.objects.create_user(id=999, username="Foo"), 'django.contrib.auth.backends.ModelBackend') | ||
self.add_force_login(id=999, username="Foo") | ||
|
||
def test_newline(self): | ||
farm = models.Farm.objects.create(name='Foo') | ||
self.client.post(reverse('hosts-add', args=[farm.pk]), { | ||
'hosts': "\naaa\nbbb\nccc \n" | ||
}, follow=False) | ||
self.assertEqual(models.Host.objects.count(), 3, 'Expected 3 hosts') | ||
self.assertCount(models.Host, 3, "Expected 3 hosts") | ||
|
||
def test_comma(self): | ||
farm = models.Farm.objects.create(name='Foo') | ||
self.client.post(reverse('hosts-add', args=[farm.pk]), { | ||
'hosts': ",,aaa, bbb,ccc," | ||
}, follow=False) | ||
self.assertEqual(models.Host.objects.count(), 3, 'Expected 3 hosts') | ||
self.assertCount(models.Host, 3, "Expected 3 hosts") |
Oops, something went wrong.