Exemplo n.º 1
0
    def test_notification_second_range_added(self):
        # first we save schedules for 8/11. Notifications are sent.
        self._save_schedule(self.user_1, 17, 18)

        for i in range(NOTIFICATION_PARTNER_THRESHOLD):
            user = test_utils.create_user(
                'a_user_{0}'.format(i), ['en'], ['es'])
            self._save_schedule(user, 16, 19)

        tasks.notify_users()
        self.assertEqual(1, len(self._user_notification_records))

        # now save schedules for days in future, after notification period.
        period_days = int(math.ceil(MIN_NOTIFICATION_PERIOD / 24.0))
        self._save_schedule(self.user_1, 17, 18, 11 + period_days)

        for i in range(NOTIFICATION_PARTNER_THRESHOLD):
            user = test_utils.create_user(
                'b_user_{0}'.format(i), ['en'], ['es'])
            self._save_schedule(user, 16, 19, 11 + period_days)

        # try to notify next day (should be before min notification period).
        # no new notifications should be sent
        tasks.utcnow = lambda: datetime(2011, 8, 12)
        tasks.notify_users()
        self.assertEqual(1, len(self._user_notification_records))

        # now notify after min period. should get a new notification.
        tasks.utcnow = lambda: datetime(2011, 8, 11 + period_days, 2)
        tasks.notify_users()
        self.assertEqual(2, len(self._user_notification_records))
Exemplo n.º 2
0
 def test_edit_account_form_displayed_correctly(self):
     # Create User and Login
     test_utils.create_user()
     self.client.login(username='******', password='******')
     # Access the edit account page
     try:
         response = self.client.get(reverse('editAccount'))
     except:
         return False
     # Check display and format of form
     # Header
     self.assertIn('<h1>Edit Account</h1>'.lower(),
                   response.content.lower())
     # Check form in response context is an instance of UserForm
     self.assertTrue(isinstance(response.context['user_form'], UserForm))
     # Check form in response context is an instance of UserProfileForm
     self.assertTrue(
         isinstance(response.context['profile_form'], UserProfileForm))
     user_form = UserForm()
     profile_form = UserProfileForm()
     # Check form is displayed correctly
     self.assertEquals(response.context['user_form'].as_p(),
                       user_form.as_p())
     self.assertEquals(response.context['profile_form'].as_p(),
                       profile_form.as_p())
     # Correct submit button
     self.assertIn('input type="submit" value="submit"', response.content)
Exemplo n.º 3
0
    def test_pages_using_templates(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        categories = test_utils.create_categories()
        # Create a list of pages to access
        pages = [
            reverse('index'),
            reverse('about'),
            reverse('add_category'),
            reverse('register'),
            reverse('login'),
            reverse('show_category', args=[categories[0].slug]),
            reverse('add_page', args=[categories[0].slug])
        ]  #, reverse('restricted')]

        # Create a list of pages to access
        templates = [
            'rango/index.html', 'rango/about.html', 'rango/add_category.html',
            'rango/register.html', 'rango/login.html', 'rango/category.html',
            'rango/add_page.html'
        ]  #, 'rango/restricted.html']

        # For each page in the page list, check if it extends from base template
        for template, page in zip(templates, pages):
            response = self.client.get(page)
            self.assertTemplateUsed(response, template)
Exemplo n.º 4
0
    def test_login_redirects_to_index(self):
        # Create a user
        test_utils.create_user()

        # Access login page via POST with user data
        response = self.client.post(reverse('login'), {'username': '******', 'password': '******'})

        # Check it redirects to index
        self.assertRedirects(response, reverse('index'))
Exemplo n.º 5
0
 def test_logout_redirects_to_index(self):
     # Create user and log in
     test_utils.create_user()
     self.client.login(username='******', password='******')
     try:
         response = self.logout()
     except:
         return False
     self.assertRedirects(response, reverse('index'))
Exemplo n.º 6
0
    def test_invalid_thread_author(self):
        op = test_utils.create_user(thread_count=1, post_count=1)
        poster = test_utils.create_user(thread_count=0, post_count=1)

        thread = Thread.objects.all()[0]
        thread.author = poster
        thread.save()

        self.assertEqual(self.cmd.check_thread_authors(), False)
Exemplo n.º 7
0
    def setUp(self):
        test_utils.create_std_forums()

        self.tu_1 = test_utils.create_user(thread_count=1)
        self.tu_2 = test_utils.create_user()

        self.thread = Thread.objects.filter(author=self.tu_1)[0]
        self.thread.subscribe(self.tu_1)
        self.thread.mark_read(self.tu_1)
Exemplo n.º 8
0
    def test_add_category_is_bootstrapped(self):
        # Create user and login
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Access add category page
        response = self.client.get(reverse('add_category'))

        #Check it uses bootstrap classes
        self.assertIn('<h2 class="form-signin-heading">', response.content)
        self.assertIn('<button class="btn btn-primary"', response.content)
Exemplo n.º 9
0
    def test_url_reference_in_category_page(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        test_utils.create_categories()

        # Check for add_page in category page
        response = self.client.get(reverse('show_category', args=['category-1']))
        self.assertIn(reverse('add_page', args=['category-1']), response.content)
Exemplo n.º 10
0
    def test_url_reference_in_category_page(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        test_utils.create_categories()

        # Check for add_page in category page
        response = self.client.get(reverse('category', args=['category-1']))
        self.assertIn(reverse('add_page', args=['category-1']), response.content)
Exemplo n.º 11
0
    def test_url_reference_in_index_page_when_logged(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Access index page
        response = self.client.get(reverse('index'))

        # Check links that appear for logged person only
        self.assertIn(reverse('add_category'), response.content)
        self.assertIn(reverse('restricted'), response.content)
        self.assertIn(reverse('logout'), response.content)
        self.assertIn(reverse('about'), response.content)
Exemplo n.º 12
0
    def test_url_reference_in_index_page_when_logged(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Access index page
        response = self.client.get(reverse('index'))

        # Check links that appear for logged person only
        self.assertIn(reverse('add_category'), response.content)
        self.assertIn(reverse('restricted'), response.content)
        self.assertIn(reverse('logout'), response.content)
        self.assertIn(reverse('about'), response.content)
Exemplo n.º 13
0
    def setUp2(self):
        self.don = test_utils.create_user()
        self.scrub = test_utils.create_user()

        self.don_client = Client()
        self.don_client.force_login(self.don)

        self.scrub_client = Client()
        self.scrub_client.force_login(self.scrub)

        AccessControlGroup.get_acg('INVITORS').members.add(self.don)

        self.path = reverse('generate-invite')
Exemplo n.º 14
0
 def test_url_reference_index_page_when_logged(self):
     # Create user and log in
     test_utils.create_user()
     self.client.login(username='******', password='******')
     # Access index page
     response = self.client.get(reverse('index'))
     # Check links that appear for logged in person
     self.assertIn(reverse('index'), response.content)
     self.assertIn(reverse('logout'), response.content)
     self.assertIn(reverse('myTeams'), response.content)
     self.assertIn(reverse('myMatches'), response.content)
     self.assertIn(reverse('gameList'), response.content)
     self.assertIn(reverse('teamList'), response.content)
Exemplo n.º 15
0
 def test_login_redirects_to_index(self):
     # Create User
     test_utils.create_user()
     # Access login page via POST with user data
     try:
         response = self.client.post(reverse('login'), {
             'username': '******',
             'password': '******'
         })
     except:
         return False
     # Check it redirects to index
     self.assertRedirects(response, reverse('index'))
Exemplo n.º 16
0
    def setUp(self):
        self.tu_1 = test_utils.create_user()
        self.tu_2 = test_utils.create_user()
        self.tu_3 = test_utils.create_user()

        self.pacl = AccessControlList(name="PERM_ACL", allow_by_default=True)
        self.pacl.save()

        self.uacl = AccessControlList(name="UPERM_ACL", allow_by_default=False)
        self.uacl.save()

        self.non_even_group = AccessControlGroup(name="ODD_USERS")
        self.non_even_group.save()
        self.non_even_group.members.add(self.tu_1)
        self.non_even_group.members.add(self.tu_3)
Exemplo n.º 17
0
    def test_job_lists_only_show_current_user(self):
        client = Client()
        current_user = test_utils.create_user("current_user", "test_password")
        other_user = test_utils.create_user("other_user", "test_password")
        logged_in = client.force_login(current_user)

        job1 = test_utils.create_job(current_user, "some_docker", "some_link")
        job2 = test_utils.create_job(other_user, "other_docker", "other_link")

        response = client.get("/jobs/")
        job_list = list(response.context["unfinished_jobs"])

        # Assert there is only the current user's job object in the list
        # assert len(job_list) == 1
        assert True  # TODO Fix this when I have time............
Exemplo n.º 18
0
 def test_user_profile_model(self):
     # Create a user
     user = test_utils.create_user()
     testUser = userProfile.objects.get_or_create(user=user)[0]
     testUser.save()
     self.assertEquals(testUser.user,
                       userProfile.objects.get(user=user).user)
Exemplo n.º 19
0
    def setUp(self):
        test_utils.create_std_forums()

        self.admin = test_utils.create_user()
        self.scrub = test_utils.create_user(thread_count=1, post_count=10)

        self.admin.is_admin = True
        self.admin.is_staff = True
        self.admin.save()

        self.thread = Thread.objects.all()[0]

        self.scrub_client = Client()
        self.scrub_client.force_login(self.scrub)
        self.admin_client = Client()
        self.admin_client.force_login(self.admin)
Exemplo n.º 20
0
    def test_job_lists_are_correct(self):
        client = Client()
        test_user = test_utils.create_user("test_user", "test_password")
        logged_in = client.force_login(test_user)
        job = test_utils.create_job(test_user, "some_docker", "some_link")
        job = test_utils.create_job(test_user,
                                    "other_docker",
                                    "other_link",
                                    finished=True)

        response = client.get("/jobs/")

        # Current system has no way of having unfinished jobs...... kinda weird but
        # uj = response.context["unfinished_jobs"][0]
        fj = response.context["finished_jobs"][0]

        #        assert (uj.config, uj.catalog_link, uj.finished) == (
        #            "some_docker",
        #            "some_link",
        #            False,
        #        )
        assert (fj.config, fj.catalog_link, fj.finished) == (
            "other_docker",
            "other_link",
            True,
        )
Exemplo n.º 21
0
 def setUp2(self):
     test_utils.create_std_forums()
     self.rikimaru = test_utils.create_user(thread_count=1, post_count=0)
     self.post = self.rikimaru.post_set.all()[0]
     self.post.created = self.post.created - timedelta(days=4)
     self.post.has_been_edited = True
     self.post.save()
Exemplo n.º 22
0
def test_create_job_without_finished_auto_fills_field_to_false():
    test_user = test_utils.create_user("test user", "test_password")
    job = Job(config="This is a config",
              catalog_link="abc.com",
              user=test_user)

    assert not job.finished
Exemplo n.º 23
0
    def test_change_password_changes_password(self):
        client = Client(enforce_csrf_checks=True)
        user = test_utils.create_user("testuser", "testpassword")
        logged_in = client.login(username="******", password="******")

        # Get the csrf token from the get response
        r = client.get(reverse("change_password"))
        token = r.context[0]["csrf_token"]

        # Change password POST request
        response = client.post(
            reverse("change_password"),
            {
                "csrfmiddlewaretoken": token,
                "old_password": "******",
                "new_password1": "newtestpassword",
                "new_password2": "newtestpassword",
            },
            follow=True,
        )

        # Logout the client and check the old password does not work and the new one does
        client.logout()
        old_login = client.login(username="******", password="******")
        logged_in = client.login(username="******",
                                 password="******")

        SimpleTestCase().assertRedirects(response, "/")
        assert not old_login
        assert logged_in
Exemplo n.º 24
0
    def test_all_templates_contain_a_page_header(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        categories = test_utils.create_categories()

        # Create a list of pages to access
        pages = [reverse('index'), reverse('about'), reverse('add_category'), reverse('registration_register'), reverse('auth_login'),
                 reverse('category', args=[categories[0].slug]), reverse('add_page', args=[categories[0].slug]),
                 reverse('restricted')]

        # For each page in the page list, check if it has a page header
        for page in pages:
            response = self.client.get(page)
            self.assertIn('<div class="page-header">', response.content)
Exemplo n.º 25
0
 def setUp2(self):
     test_utils.create_std_forums()
     self.scrub = test_utils.create_user(thread_count=1, post_count=0)
     self.thread = Thread.objects.get(author=self.scrub)
     self.scrub_client = Client()
     self.scrub_client.force_login(self.scrub)
     self.path = reverse('new-reply', args=(self.thread.pk, ))
     self.limit = utils.get_config('initial_account_period_limit')
Exemplo n.º 26
0
    def test_get_change_password(self):
        client = Client()
        user = test_utils.create_user("testuser", "testpassword")
        logged_in = client.force_login(user)
        response = client.get(reverse("change_password"), follow=True)

        assert response.status_code == 200
        self.assertTemplateUsed(response, "change_password.html")
Exemplo n.º 27
0
def test_create_job_without_user_raises_integrity_error():
    test_user = test_utils.create_user("test user", "test_password")
    job = Job(finished=False,
              config="this is a config.",
              catalog_link="abc.com")

    with pytest.raises(django.db.utils.IntegrityError):
        job.save()
Exemplo n.º 28
0
    def setUp2(self):
        test_utils.create_std_forums()

        self.scrub = test_utils.create_user(thread_count=5, post_count=10)
        self.scrub.auto_subscribe = 1
        self.scrub.save()

        self.scrub_client = Client()
        self.scrub_client.force_login(self.scrub)
Exemplo n.º 29
0
    def setUp(self):
        self.password = u'私わ大津展之です'
        self.path = reverse('login')

        self.otsu = test_utils.create_user()
        self.otsu.set_password(self.password)
        self.otsu.save()

        self.otsu_client = Client()
Exemplo n.º 30
0
    def test_templates_inherits_from_base_template(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        categories = test_utils.create_categories()

        # Create a list of pages to access
        pages = [reverse('index'), reverse('about'), reverse('add_category'), reverse('register'), reverse('login'),
                 reverse('category', args=[categories[0].slug]), reverse('add_page', args=[categories[0].slug]),
                 reverse('restricted')]

        # For each page in the page list, check if it extends from base template
        for page in pages:
            response = self.client.get(page)
            base_html = loader.get_template('base.html')
            self.assertTrue(any(base_html.name == template.name for template in response.templates))
Exemplo n.º 31
0
    def setUp(self):
        self.franz = test_utils.create_user()
        self.franz.email = '*****@*****.**'
        self.franz.save()

        self.franz_client = Client()
        self.franz_client.force_login(self.franz)

        self.issue_path = reverse('recovery-initiate')
        self.reset_path = reverse('recovery-reset')
Exemplo n.º 32
0
    def test_titles_displayed(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        categories = test_utils.create_categories()

        # Access index and check the title displayed
        response = self.client.get(reverse('index'))
        self.assertIn('Rango -'.lower(), response.content.lower())

        # Access category page and check the title displayed
        response = self.client.get(
            reverse('show_category', args=[categories[0].slug]))
        self.assertIn(categories[0].name.lower(), response.content.lower())

        # Access about page and check the title displayed
        response = self.client.get(reverse('about'))
        self.assertIn('About'.lower(), response.content.lower())

        # Access login page and check the title displayed
        response = self.client.get(reverse('login'))
        self.assertIn('Login'.lower(), response.content.lower())

        # Access register page and check the title displayed
        response = self.client.get(reverse('register'))
        self.assertIn('Register'.lower(), response.content.lower())

        # Access restricted page and check the title displayed
        response = self.client.get(reverse('restricted'))
        self.assertIn("Since you're logged in".lower(),
                      response.content.lower())

        # Access add page and check the title displayed
        response = self.client.get(
            reverse('add_page', args=[categories[0].slug]))
        self.assertIn('Add Page'.lower(), response.content.lower())

        # Access add new category page and check the title displayed
        response = self.client.get(reverse('add_category'))
        self.assertIn('Add Category'.lower(), response.content.lower())
Exemplo n.º 33
0
 def test_create_team_form_displayed_correctly(self):
     test_utils.create_user()
     self.client.login(username='******', password='******')
     # Access the create team page
     try:
         response = self.client.get(reverse('createTeam'))
     except:
         return False
     # Check display and format of form
     # Header
     self.assertIn('<h1>Create a Team</h1>'.lower(),
                   response.content.lower())
     # Check form in response context is an instance of UserForm
     self.assertTrue(isinstance(response.context['form'], TeamForm))
     team_form = TeamForm()
     # Check form is displayed correctly
     self.assertEquals(response.context['form'].as_p(), team_form.as_p())
     # Correct submit button
     self.assertIn('input type="submit" name="submit" value="Create Team"',
                   response.content)
Exemplo n.º 34
0
    def test_pages_using_templates(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        categories = test_utils.create_categories()
        # Create a list of pages to access
        pages = [reverse('index'), reverse('about'), reverse('add_category'), reverse('register'), reverse('login'),
                 reverse('category', args=[categories[0].slug]), reverse('add_page', args=[categories[0].slug]),
                 reverse('restricted')]

        # Create a list of pages to access
        templates = ['rango/index.html', 'rango/about.html', 'rango/add_category.html', 'rango/register.html',
                     'rango/login.html','rango/category.html', 'rango/add_page.html', 'rango/restricted.html']

        # For each page in the page list, check if it extends from base template
        for template, page in zip(templates, pages):
            response = self.client.get(page)
            self.assertTemplateUsed(response, template)
Exemplo n.º 35
0
    def setUp2(self):
        test_utils.create_std_forums()

        self.admin = test_utils.create_user()
        self.anon_client = Client()

        self.reg_code = RegistrationCode()
        self.reg_code.generated_by = self.admin
        self.reg_code.save()

        self.path = reverse('register-with-code')
Exemplo n.º 36
0
    def test_links_are_updated_in_base_template(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Access index page
        response = self.client.get(reverse('index'))

        # Check links that appear for logged person only
        self.assertIn(reverse('auth_logout'), response.content)

        #Log out
        self.client.logout()

        #Access index page with user not logged
        response = self.client.get(reverse('index'))

        # Check links that appear for logged person only
        self.assertIn(reverse('registration_register'), response.content)
        self.assertIn(reverse('auth_login'), response.content)
Exemplo n.º 37
0
    def setUp(self):
        self.limit = utils.get_config()['initial_account_period_total'] = 3

        test_utils.create_std_forums()

        self.thankee = test_utils.create_user(thread_count=1, post_count=4)
        self.thanker = test_utils.create_user(post_count=4)
        self.noob_thanker = test_utils.create_user(post_count=1)

        self.thanker_client = Client()
        self.thanker_client.force_login(self.thanker)

        self.noob_thanker_client = Client()
        self.noob_thanker_client.force_login(self.noob_thanker)

        self.thankee_client = Client()
        self.thankee_client.force_login(self.thankee)

        self.url = reverse('thank-post',
                           args=(self.thankee.post_set.all()[0].pk, ))
Exemplo n.º 38
0
def test_create_job_entry():
    test_user = test_utils.create_user("test user", "test_password")
    job = Job(
        finished=False,
        config="this is a config.",
        catalog_link="abc.com",
        user=test_user,
    )

    job.save()

    assert len(Job.objects.all()) == 1
Exemplo n.º 39
0
    def test_titles_displayed(self):
        # Create user and log in
        test_utils.create_user()
        self.client.login(username='******', password='******')

        # Create categories
        categories = test_utils.create_categories()

        # Access index and check the title displayed
        response = self.client.get(reverse('index'))
        self.assertIn('<title>Rango - How to Tango with Django!</title>', response.content)

        # Access category page and check the title displayed
        response = self.client.get(reverse('category', args=[categories[0].slug]))
        self.assertIn('<title>Rango - ' + categories[0].name + '</title>', response.content)

        # Access about page and check the title displayed
        response = self.client.get(reverse('about'))
        self.assertIn('<title>Rango - About</title>', response.content)

        # Access login page and check the title displayed
        response = self.client.get(reverse('login'))
        self.assertIn('<title>Rango - Login</title>', response.content)

        # Access register page and check the title displayed
        response = self.client.get(reverse('register'))
        self.assertIn('<title>Rango - Register</title>', response.content)

        # Access restricted page and check the title displayed
        response = self.client.get(reverse('restricted'))
        self.assertIn('<title>Rango - Restricted Page</title>', response.content)

        # Access add page and check the title displayed
        response = self.client.get(reverse('add_page', args=[categories[0].slug]))
        self.assertIn('<title>Rango - Add Page</title>', response.content)

        # Access add new category page and check the title displayed
        response = self.client.get(reverse('add_category'))
        self.assertIn('<title>Rango - Add Category</title>', response.content)
Exemplo n.º 40
0
    def test_user_profile_model(self):
        # Create a user
        user, user_profile = test_utils.create_user()

        # Check there is only the saved user and its profile in the database
        all_users = User.objects.all()
        self.assertEquals(len(all_users), 1)

        all_profiles = UserProfile.objects.all()
        self.assertEquals(len(all_profiles), 1)

        # Check profile fields were saved correctly
        all_profiles[0].user = user
        all_profiles[0].website = user_profile.website
Exemplo n.º 41
0
    def test_user_profile_model(self):
        # Create a user
        user, user_profile = test_utils.create_user()

        # Check there is only the saved user and its profile in the database
        all_users = User.objects.all()
        self.assertEquals(len(all_users), 1)

        all_profiles = UserProfile.objects.all()
        self.assertEquals(len(all_profiles), 1)

        # Check profile fields were saved correctly
        all_profiles[0].user = user
        all_profiles[0].website = user_profile.website
Exemplo n.º 42
0
    def test_notification(self):
        self._save_schedule(self.user_1, 17, 18)

        for i in range(NOTIFICATION_PARTNER_THRESHOLD * 2):
            offset = (i % 2) * 2
            user = test_utils.create_user(
                'user_{0}'.format(i), ['en'], ['es'])
            self._save_schedule(user, 17 - offset, 18 - offset)
            tasks.notify_users()
            self.assertEqual(
                0 if i < NOTIFICATION_PARTNER_THRESHOLD * 2 - 2 else 1,
                len(self._user_notification_records))
        user_notification = self._user_notification_records[0]
        self.assertEqual(
            1, len(user_notification.usernotificationrange_set.all()))
Exemplo n.º 43
0
    def test_admin_contains_user_profile(self):
        # Access admin page
        self.browser.get(self.live_server_url + reverse('admin:index'))

        # Log in the admin page
        test_utils.login(self)

        # Check exists a link to user profiles
        self.browser.find_element_by_link_text('User profiles').click()

        # Check it is empty
        body = self.browser.find_element_by_tag_name('body')
        self.assertIn('0 user profiles', body.text)

        # create a user
        user, user_profile = test_utils.create_user()

        self.browser.refresh()

        # Check there is one profile
        body = self.browser.find_element_by_tag_name('body')
        self.assertIn(user.username, body.text)
Exemplo n.º 44
0
    def test_notification_multiple_ranges(self):
        request = RequestMockup(self.user_1)
        rpc.save_schedule(
            request,
            _schedule_arg_for_times([[11, 17, 11, 18], 
                                     [12, 17, 12, 18], 
                                     [13, 17, 13, 18]]),
            2011, 8, 11, TIME_RANGE)
        for i in range(NOTIFICATION_PARTNER_THRESHOLD):
            user = test_utils.create_user(
                'a_user_{0}'.format(i), ['en'], ['es'])
            request = RequestMockup(user)
            times = [[11, 17, 11, 17], [12, 17, 12, 18]]
            if i < NOTIFICATION_PARTNER_THRESHOLD / 2:
                times.append([13, 17, 13, 18])
            rpc.save_schedule(request, _schedule_arg_for_times(times),
                              2011, 8, 11, TIME_RANGE)

        tasks.notify_users()
        self.assertEquals(1, len(self._user_notification_records))
        notification_record = self._user_notification_records[0]
        # user_1 should be notified for 2 ranges, not 1 or 3.
        self.assertEqual(
            2, len(notification_record.usernotificationrange_set.all()))