Exemplo n.º 1
0
    def setUp(self):
        org = create_organisation("Heavy Users", num_teams=1, num_members=8)
        # user variable names here are ordered by usage
        self.top_user_1 = org.team_set.all()[0].user_set.all()[4]
        self.top_user_2 = org.team_set.all()[0].user_set.all()[2]
        self.top_user_3 = org.team_set.all()[0].user_set.all()[3]
        self.top_user_4 = org.team_set.all()[0].user_set.all()[1]
        self.top_user_5 = org.team_set.all()[0].user_set.all()[0]
        self.top_user_6 = org.team_set.all()[0].user_set.all()[6]

        self.owner_user = org.team_set.all()[0].user_set.all()[5]

        self.used_link, = generate_fake_links(self.owner_user, 2)

        register_link_usage_for_user(self.used_link, self.top_user_1, 13)
        register_link_usage_for_user(self.used_link, self.top_user_2, 12)
        register_link_usage_for_user(self.used_link, self.top_user_3, 10)
        register_link_usage_for_user(self.used_link, self.top_user_4, 9)
        register_link_usage_for_user(self.used_link, self.top_user_5, 7)
        register_link_usage_for_user(self.used_link, self.top_user_6, 5)
        register_link_usage_for_user(self.used_link, self.owner_user, 4)

        login_user(self, self.owner_user)

        # We need this for time mocking.
        self.now = now()
Exemplo n.º 2
0
    def setUp(self):
        org = create_organisation(
            'Heavy Users',
            num_teams=1,
            num_members=8,
        )
        # user variable names here are ordered by usage
        self.top_user_1 = org.team_set.all()[0].user_set.all()[4]
        self.top_user_2 = org.team_set.all()[0].user_set.all()[2]
        self.top_user_3 = org.team_set.all()[0].user_set.all()[3]
        self.top_user_4 = org.team_set.all()[0].user_set.all()[1]
        self.top_user_5 = org.team_set.all()[0].user_set.all()[0]
        self.top_user_6 = org.team_set.all()[0].user_set.all()[6]

        self.owner_user = org.team_set.all()[0].user_set.all()[5]

        self.used_link, = generate_fake_links(self.owner_user, 2)

        register_link_usage_for_user(self.used_link, self.top_user_1, 13)
        register_link_usage_for_user(self.used_link, self.top_user_2, 12)
        register_link_usage_for_user(self.used_link, self.top_user_3, 10)
        register_link_usage_for_user(self.used_link, self.top_user_4, 9)
        register_link_usage_for_user(self.used_link, self.top_user_5, 7)
        register_link_usage_for_user(self.used_link, self.top_user_6, 5)
        register_link_usage_for_user(self.used_link, self.owner_user, 4)

        login_user(self, self.owner_user)

        # We need this for time mocking.
        self.now = now()
    def test_join_leave_buttons_work(self):
        #   Create an organisation, a team and a user and assign that
        #   team to that user.
        o = Organisation(name="org0001")
        o.save()
        t = Team(name="team0001", organisation=o)
        t.save()
        u = get_user_model().objects.create_user(userid='*****@*****.**')
        login_user(self, u)

        response = self.app.get(reverse('team-detail', kwargs={'pk': t.pk}))

        form = response.form

        self.assertEqual(form.method, 'post')

        self.assertEqual(form.action, '/teams/' + str(t.pk) + '/join')

        response = form.submit().follow()

        # Make sure the user is now in the team
        response = self.app.get(reverse('user-detail', kwargs={'slug':
                                                               u.slug}))

        self.assertTrue(
            response.html.find('a',
                               attrs={
                                   'class': 'main-list-item',
                                   'href': '/teams/' + str(t.pk)
                               }))

        # Go back to the team detail page so we can submit the link
        response = self.app.get(reverse('team-detail', kwargs={'pk': t.pk}))

        form = response.form

        self.assertEqual(form.method, 'post')

        self.assertEqual(form.action, '/teams/' + str(t.pk) + '/leave')

        response = form.submit().follow()

        # Make sure the user is no longer in the team
        response = self.app.get(reverse('user-detail', kwargs={'slug':
                                                               u.slug}))
        self.assertFalse(
            response.html.find('a',
                               attrs={
                                   'class': 'main-list-item',
                                   'href': '/teams/' + str(t.pk)
                               }))
    def setUp(self):
        self.logged_in_user = make_user()

        (self.el1, self.el2, self.el3,) = generate_fake_links(
            self.logged_in_user,
            count=3
        )

        self.el1.categories.add('mapping')
        self.el1.save()

        self.el2.categories.add('mapping')
        self.el2.save()

        self.el3.categories.add('social')
        self.el3.save()

        self.el3.name = 'Unique'
        self.el3.save()

        self.logged_in_user.favourites.add(self.el2)
        self.logged_in_user.favourites.add(self.el3)

        self.assertTrue(login_user(self, self.logged_in_user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
    def setUp(self):
        self.logged_in_user = make_user()

        (
            self.el1,
            self.el2,
            self.el3,
        ) = generate_fake_links(self.logged_in_user, count=3)

        self.el1.categories.add('mapping')
        self.el1.save()

        self.el2.categories.add('mapping')
        self.el2.save()

        self.el3.categories.add('social')
        self.el3.save()

        self.el3.name = 'Unique'
        self.el3.save()

        self.logged_in_user.favourites.add(self.el2)
        self.logged_in_user.favourites.add(self.el3)

        self.assertTrue(login_user(self, self.logged_in_user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
Exemplo n.º 6
0
 def setUp(self):
     self.logged_in_user = make_user()
     self.other_user = make_user(
         userid='other_user',
         email='*****@*****.**',
         name='Fake2 Fakerly')
     self.assertTrue(login_user(self, self.logged_in_user))
    def setUp(self):
        self.user = make_user()
        (self.el1, self.el2, self.el3, self.el4, self.el5, self.el6, self.el7,
         self.el8) = generate_fake_links(self.user, count=8)

        self.el1.categories.add('great')
        self.el2.categories.add('great')
        self.el3.categories.add('great')
        self.el4.categories.add('great')
        self.el5.categories.add('great')
        self.el6.categories.add('great')

        self.el7.is_external = True
        self.el7.save()

        self.el8.is_external = True
        self.el8.save()

        self.assertTrue(login_user(self, self.user))

        self.unfound_link_1 = Link.objects.create(
            name='Google Translate',
            destination='https://mail.google.com',
            description='Internet translation',
            owner=self.user,
        )

        self.unfound_link_2 = Link.objects.create(
            name='Google Mail',
            destination='https://translate.google.com',
            description='Internet email',
            owner=self.user,
        )

        rebuild_index.Command().handle(interactive=False, verbosity=0)
Exemplo n.º 8
0
    def setUp(self):
        self.user = make_user(userid='*****@*****.**',
                              email='*****@*****.**',
                              name='Ant Anterton')

        self.box_user = make_user(userid='*****@*****.**',
                                  email='*****@*****.**',
                                  name='Box Boxerly')

        self.chair_user = make_user(userid='*****@*****.**',
                                    email='*****@*****.**',
                                    name='Chair Chairington')

        self.first_desk_user = make_user(userid='*****@*****.**',
                                         email='*****@*****.**',
                                         name='Desk Deskworth')

        self.second_desk_user = make_user(userid='*****@*****.**',
                                          email='*****@*****.**',
                                          name='Desk Desker')

        self.eagle_user = make_user(userid='*****@*****.**',
                                    email='*****@*****.**',
                                    name='Eagle Eagerly')

        self.feather_user = make_user(userid='featherfeatherly',
                                      email='*****@*****.**',
                                      name='')

        self.assertTrue(login_user(self, self.user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
Exemplo n.º 9
0
    def setUp(self):
        self.logged_in_user = make_user()
        self.assertTrue(login_user(self, self.logged_in_user))

        self.el1, = generate_fake_links(
            self.logged_in_user,
            count=1,
            is_external=True
        )
    def setUp(self):
        self.logged_in_user = make_user()

        el1, el2 = generate_fake_links(self.logged_in_user, count=2)

        self.existing_link_1 = el1

        self.existing_link_2 = el2

        self.assertTrue(login_user(self, self.logged_in_user))
    def setUp(self):
        self.logged_in_user = make_user()
        self.assertTrue(login_user(self, self.logged_in_user))

        self.el1, self.el2, = generate_fake_links(self.logged_in_user,
                                                  count=2,
                                                  is_external=True)

        self.logged_in_user.favourites.add(self.el1)
        self.logged_in_user.favourites.add(self.el2)
Exemplo n.º 12
0
    def test_lighthouse_api_edit_page_has_no_destination_box(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-edit', kwargs={'pk': 2}))

        dest_input = response.html.find('input', {'name': 'destination'})

        self.assertEqual(dest_input.attrs['type'], 'hidden')
Exemplo n.º 13
0
    def test_lighthouse_api_edit_page_has_no_destination_box(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-edit', kwargs={'pk': 2}))

        dest_input = response.html.find('input', {'name': 'destination'})

        self.assertEqual(dest_input.attrs['type'], 'hidden')
Exemplo n.º 14
0
    def test_normal_edit_page_has_destination_box(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))
        link, = generate_fake_links(owner=self.logged_in_user)

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-edit', kwargs={'pk': link.id}))

        dest_input = response.html.find('input', {'name': 'destination'})

        self.assertEqual(dest_input.attrs['type'], 'url')
Exemplo n.º 15
0
    def setUp(self):
        self.logged_in_user = make_user()
        self.assertTrue(login_user(self, self.logged_in_user))

        self.el1, self.el2, = generate_fake_links(
            self.logged_in_user,
            count=2,
            is_external=True
        )

        self.logged_in_user.favourites.add(self.el1)
        self.logged_in_user.favourites.add(self.el2)
Exemplo n.º 16
0
    def test_normal_edit_page_has_destination_box(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))
        link, = generate_fake_links(owner=self.logged_in_user)

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-edit', kwargs={'pk': link.id}))

        dest_input = response.html.find('input', {'name': 'destination'})

        self.assertEqual(dest_input.attrs['type'], 'url')
Exemplo n.º 17
0
    def test_editor_stack_stored(self):
        form = self.app.get(
            reverse('link-edit', kwargs={'pk': self.existing_link.pk})).form

        # Edit with the first editor
        self.assertEquals(form['name'].value, 'Wikimapia')
        self.assertEquals(form['description'].value,
                          'A great mapping application')
        self.assertEquals(form['destination'].value, 'https://wikimapia.org')

        form['name'].value = 'Bing Maps'
        form['description'].value = 'A brilliant free mapping application'
        form['destination'].value = 'https://maps.bing.com'

        response = form.submit()

        # Login as the second editor
        self.assertTrue(login_user(self, self.second_editor))

        form = self.app.get(
            reverse('link-edit', kwargs={'pk': self.existing_link.pk})).form

        # Edit with the second editor
        form['name'].value = 'Panoramio'
        form['description'].value = 'A super free mapping application'
        form['destination'].value = 'https://panoramio.com'
        # So we can make sure it works in both cases
        form['is_external'].select('True')

        response = form.submit().follow()

        self.assertIn('Panoramio', response)
        self.assertNotIn('Bing Maps', response)
        self.assertIn('A super free mapping application', response)
        self.assertNotIn('A brilliant mapping application', response)
        self.assertIn('https://panoramio.com', response)
        self.assertNotIn('https://maps.bing.com', response)

        owner_element = response.html.find(None, {'id': 'link_owner'})

        # Only show the most recent edit's author
        self.assertIn(str(self.owner_user), owner_element.text)
        self.assertNotIn(str(self.first_editor), owner_element.text)
        self.assertIn(str(self.second_editor), owner_element.text)

        # Store all the edits
        edits_oldest_first = self.existing_link.edits.order_by('date').all()
        self.assertEqual(edits_oldest_first[0].user, self.first_editor)
        self.assertEqual(edits_oldest_first[1].user, self.second_editor)
        self.assertTrue(
            edits_oldest_first[1].date > edits_oldest_first[0].date
        )
Exemplo n.º 18
0
    def setUp(self):
        self.logged_in_user = make_user()
        self.assertTrue(login_user(self, self.logged_in_user))

        self.existing_link = Link(
            name='Tweetbot',
            description='A great twitter application',
            destination='https://tweetbot.com',
            owner=self.logged_in_user,)
        self.existing_link.save()
        self.existing_link.categories.add('social')
        self.existing_link.categories.add('imagery')
        self.existing_link.save()
Exemplo n.º 19
0
    def setUp(self):
        self.logged_in_user = make_user()

        el1, el2 = generate_fake_links(
            self.logged_in_user,
            count=2
        )

        self.existing_link_1 = el1

        self.existing_link_2 = el2

        self.assertTrue(login_user(self, self.logged_in_user))
Exemplo n.º 20
0
    def test_lighthouse_api_page_has_no_goto_link(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-detail', kwargs={'pk': 2}))

        goto_button = response.html.find(None, {'id': 'link_follow_button'})
        goto_url = response.html.find(None, {'id': 'link_follow_url'})

        self.assertIsNone(goto_button)
        self.assertIsNone(goto_url)
    def test_editor_stack_stored(self):
        form = self.app.get(
            reverse('link-edit', kwargs={'pk': self.existing_link.pk})).form

        # Edit with the first editor
        self.assertEquals(form['name'].value, 'Wikimapia')
        self.assertEquals(form['description'].value,
                          'A great mapping application')
        self.assertEquals(form['destination'].value, 'https://wikimapia.org')

        form['name'].value = 'Bing Maps'
        form['description'].value = 'A brilliant free mapping application'
        form['destination'].value = 'https://maps.bing.com'

        response = form.submit()

        # Login as the second editor
        self.assertTrue(login_user(self, self.second_editor))

        form = self.app.get(
            reverse('link-edit', kwargs={'pk': self.existing_link.pk})).form

        # Edit with the second editor
        form['name'].value = 'Panoramio'
        form['description'].value = 'A super free mapping application'
        form['destination'].value = 'https://panoramio.com'
        # So we can make sure it works in both cases
        form['is_external'].select('True')

        response = form.submit().follow()

        self.assertIn('Panoramio', response)
        self.assertNotIn('Bing Maps', response)
        self.assertIn('A super free mapping application', response)
        self.assertNotIn('A brilliant mapping application', response)
        self.assertIn('https://panoramio.com', response)
        self.assertNotIn('https://maps.bing.com', response)

        owner_element = response.html.find(None, {'id': 'link_owner'})

        # Only show the most recent edit's author
        self.assertIn(str(self.owner_user), owner_element.text)
        self.assertNotIn(str(self.first_editor), owner_element.text)
        self.assertIn(str(self.second_editor), owner_element.text)

        # Store all the edits
        edits_oldest_first = self.existing_link.edits.order_by('date').all()
        self.assertEqual(edits_oldest_first[0].user, self.first_editor)
        self.assertEqual(edits_oldest_first[1].user, self.second_editor)
        self.assertTrue(
            edits_oldest_first[1].date > edits_oldest_first[0].date)
    def setUp(self):
        self.logged_in_user = make_user()

        (self.el1, ) = generate_fake_links(self.logged_in_user, count=1)

        (self.el2, ) = generate_fake_links(self.logged_in_user,
                                           is_external=True,
                                           count=1)

        self.el1.categories.add('social')
        self.el1.save()

        self.el2.categories.add('mapping')
        self.el2.save()

        self.assertTrue(login_user(self, self.logged_in_user))
Exemplo n.º 23
0
    def setUp(self):
        self.user = make_user()
        self.assertTrue(login_user(self, self.user))

        self.link = Link.objects.create(
            name='Link Linkerly',
            destination='https://here/',
            owner=self.user,
            is_external=False,
        )
        self.other_link = Link.objects.create(
            name='Other Link',
            destination='https://here/links',
            owner=self.user,
            is_external=True,
        )
        self.now = now()
    def setUp(self):
        self.owner_user = make_user(userid='owner',
                                    email='*****@*****.**',
                                    name='Owner User')
        self.existing_link = Link(name='Wikimapia',
                                  description='A great mapping application',
                                  destination='https://wikimapia.org',
                                  owner=self.owner_user)
        self.existing_link.save()

        self.first_editor = make_user(userid='first_editor',
                                      email='*****@*****.**',
                                      name='First Editor')
        self.second_editor = make_user(userid='second_editor',
                                       email='*****@*****.**')

        self.assertTrue(login_user(self, self.first_editor))
Exemplo n.º 25
0
    def setUp(self):
        self.user = make_user()
        self.assertTrue(login_user(self, self.user))

        self.link = Link.objects.create(
            name='Link Linkerly',
            destination='https://here/',
            owner=self.user,
            is_external=False,
        )
        self.other_link = Link.objects.create(
            name='Other Link',
            destination='https://here/links',
            owner=self.user,
            is_external=True,
        )
        self.now = now()
Exemplo n.º 26
0
    def setUp(self):
        self.user = make_user()
        self.link = Link.objects.create(
            name='Google',
            destination='https://google.com',
            description='Internet search',
            owner=self.user,
            is_external=False,
        )

        self.link.categories.add('search')

        self.other_link = Link.objects.create(
            name='Google Mail',
            destination='https://mail.google.com',
            description='Internet email',
            owner=self.user,
            is_external=True,
        )

        self.other_link.categories.add('email')
        self.other_link.categories.add('search')

        self.third_link = Link.objects.create(
            name='Google Chat',
            destination='https://chat.google.com',
            description='Internet chat',
            owner=self.user,
            is_external=True,
        )

        self.third_link.categories.add('chat')

        self.fourth_link = Link.objects.create(
            name='Bing Translate',
            destination='https://translate.bing.com',
            description="Bing's a pretty good translation service. Run, yeah?",
            owner=self.user,
            is_external=True,
        )

        self.fourth_link.categories.add('language')
        self.assertTrue(login_user(self, self.user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
Exemplo n.º 27
0
    def setUp(self):
        self.logged_in_user = make_user()
        self.assertTrue(login_user(self, self.logged_in_user))

        self.external_link = Link(
            name='Tweetbot',
            description='A great twitter application',
            destination='https://tweetbot.com',
            owner=self.logged_in_user,
            is_external=True,)
        self.external_link.save()

        self.internal_link = Link(
            name='Not Wikimapia',
            description='Pretend this is not Wikimapia',
            destination='https://wikimapia.org',
            owner=self.logged_in_user,
            is_external=False,)
        self.internal_link.save()
    def test_every_authenticated_page_hit_generates_usage(self):
        self.logged_in_user = make_user()

        # This should not create usage, since they aren't logged in
        self.app.get(reverse('login'))

        # Three usages here
        self.assertTrue(login_user(self, self.logged_in_user))
        self.app.get(reverse('user-list'))
        self.app.get(reverse('link-list'))

        lighthouse_link = Link.objects.get(pk=1)
        self.assertEqual(lighthouse_link.name, 'Lighthouse')

        all_usage = LinkUsage.objects.all()

        self.assertEqual(len(all_usage), 1)

        self.assertEqual(all_usage[0].link, lighthouse_link)
        self.assertEqual(all_usage[0].user, self.logged_in_user)
Exemplo n.º 29
0
    def test_lighthouse_api_edit_page_can_submit(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-edit', kwargs={'pk': 2}))
        form = response.form

        new_desc = 'I love the Lighthouse API'
        form['description'] = new_desc

        response = form.submit().follow()

        error_summary = response.html.find('div', {"class": "error-summary"})
        self.assertIsNone(error_summary)

        description = response.html.find('div', {"class": "markdown-content"})

        self.assertIn(new_desc, description.text)
    def setUp(self):
        self.logged_in_user = make_user()
        self.assertTrue(login_user(self, self.logged_in_user))

        self.external_link = Link(
            name='Tweetbot',
            description='A great twitter application',
            destination='https://tweetbot.com',
            owner=self.logged_in_user,
            is_external=True,
        )
        self.external_link.save()

        self.internal_link = Link(
            name='Not Wikimapia',
            description='Pretend this is not Wikimapia',
            destination='https://wikimapia.org',
            owner=self.logged_in_user,
            is_external=False,
        )
        self.internal_link.save()
Exemplo n.º 31
0
    def setUp(self):
        self.logged_in_user = make_user()

        (self.el1,) = generate_fake_links(
            self.logged_in_user,
            count=1
        )

        (self.el2,) = generate_fake_links(
            self.logged_in_user,
            is_external=True,
            count=1
        )

        self.el1.categories.add('social')
        self.el1.save()

        self.el2.categories.add('mapping')
        self.el2.save()

        self.assertTrue(login_user(self, self.logged_in_user))
Exemplo n.º 32
0
    def setUp(self):
        self.owner_user = make_user(
            userid='owner',
            email='*****@*****.**',
            name='Owner User')
        self.existing_link = Link(
            name='Wikimapia',
            description='A great mapping application',
            destination='https://wikimapia.org',
            owner=self.owner_user)
        self.existing_link.save()

        self.first_editor = make_user(
            userid='first_editor',
            email='*****@*****.**',
            name='First Editor')
        self.second_editor = make_user(
            userid='second_editor',
            email='*****@*****.**')

        self.assertTrue(login_user(self, self.first_editor))
Exemplo n.º 33
0
    def test_lighthouse_api_edit_page_can_submit(self):
        self.logged_in_user = make_user()
        self.app.get(reverse('login'))

        self.assertTrue(login_user(self, self.logged_in_user))

        response = self.app.get(reverse('link-edit', kwargs={'pk': 2}))
        form = response.form

        new_desc = 'I love the Lighthouse API'
        form['description'] = new_desc

        response = form.submit().follow()

        error_summary = response.html.find('div', {"class": "error-summary"})
        self.assertIsNone(error_summary)

        description = response.html.find(
            'div', {"class": "markdown-content"})

        self.assertIn(new_desc, description.text)
Exemplo n.º 34
0
    def setUp(self):
        self.logged_in_user = make_user()

        (self.el1, self.el2, self.el3,
            self.el4, self.el5, self.el6) = generate_fake_links(
            self.logged_in_user,
            count=6
        )

        self.el7, = generate_fake_links(
            self.logged_in_user,
            start=7,
            count=1,
            is_external=True,
        )

        self.el1.categories.add('mapping')
        self.el1.categories.add('social')
        self.el1.save()

        self.el2.categories.add('mapping')
        self.el2.save()

        self.el3.categories.add('social')
        self.el3.save()

        self.el4.categories.add('geospatial')
        self.el4.save()

        self.el5.categories.add('imagery')
        self.el5.save()

        self.el6.categories.add('geospatial')
        self.el6.categories.add('mapping')
        self.el6.save()

        self.assertTrue(login_user(self, self.logged_in_user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
Exemplo n.º 35
0
    def setUp(self):
        self.user = make_user(
            userid='*****@*****.**',
            email='*****@*****.**',
            name='Ant Anterton')

        self.box_user = make_user(
            userid='*****@*****.**',
            email='*****@*****.**',
            name='Box Boxerly')

        self.chair_user = make_user(
            userid='*****@*****.**',
            email='*****@*****.**',
            name='Chair Chairington')

        self.first_desk_user = make_user(
            userid='*****@*****.**',
            email='*****@*****.**',
            name='Desk Deskworth')

        self.second_desk_user = make_user(
            userid='*****@*****.**',
            email='*****@*****.**',
            name='Desk Desker')

        self.eagle_user = make_user(
            userid='*****@*****.**',
            email='*****@*****.**',
            name='Eagle Eagerly')

        self.feather_user = make_user(
            userid='featherfeatherly',
            email='*****@*****.**',
            name='')

        self.assertTrue(login_user(self, self.user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
    def setUp(self):
        self.user = make_user()
        (self.el1, self.el2, self.el3,
            self.el4, self.el5, self.el6,
            self.el7, self.el8) = generate_fake_links(
            self.user,
            count=8
        )

        self.el1.categories.add('great')
        self.el2.categories.add('great')
        self.el3.categories.add('great')
        self.el4.categories.add('great')
        self.el5.categories.add('great')
        self.el6.categories.add('great')

        self.el7.is_external = True
        self.el7.save()

        self.el8.is_external = True
        self.el8.save()

        self.assertTrue(login_user(self, self.user))

        self.unfound_link_1 = Link.objects.create(
            name='Google Translate',
            destination='https://mail.google.com',
            description='Internet translation',
            owner=self.user,
        )

        self.unfound_link_2 = Link.objects.create(
            name='Google Mail',
            destination='https://translate.google.com',
            description='Internet email',
            owner=self.user,
        )

        rebuild_index.Command().handle(interactive=False, verbosity=0)
Exemplo n.º 37
0
    def setUp(self):
        self.logged_in_user = make_user()

        self.el1, self.el2, self.el3 = generate_fake_links(self.logged_in_user, count=3, is_external=True)

        self.el4, self.el5 = generate_fake_links(self.logged_in_user, start=4, count=2)

        # Note: the generator expects to send out a tuple, so allow that.
        (self.el6,) = generate_fake_links(self.logged_in_user, start=6, count=1, is_external=True)

        (self.el7,) = generate_fake_links(self.logged_in_user, start=7, count=1)

        self.el1.categories.add("mapping")
        self.el1.categories.add("social")
        self.el1.save()

        self.el2.categories.add("mapping")
        self.el2.save()

        self.el3.categories.add("social")
        self.el3.save()

        self.el4.categories.add("geospatial")
        self.el4.save()

        self.el5.categories.add("imagery")
        self.el5.save()

        self.el6.categories.add("geospatial")
        self.el6.categories.add("mapping")
        self.el6.save()

        self.el7.categories.add("social")
        self.el7.categories.add("mapping")
        self.el7.save()

        self.assertTrue(login_user(self, self.logged_in_user))
Exemplo n.º 38
0
    def setUp(self):
        self.logged_in_user = make_user()

        (self.el1, self.el2, self.el3, self.el4, self.el5,
         self.el6) = generate_fake_links(self.logged_in_user, count=6)

        self.el7, = generate_fake_links(
            self.logged_in_user,
            start=7,
            count=1,
            is_external=True,
        )

        self.el1.categories.add('mapping')
        self.el1.categories.add('social')
        self.el1.save()

        self.el2.categories.add('mapping')
        self.el2.save()

        self.el3.categories.add('social')
        self.el3.save()

        self.el4.categories.add('geospatial')
        self.el4.save()

        self.el5.categories.add('imagery')
        self.el5.save()

        self.el6.categories.add('geospatial')
        self.el6.categories.add('mapping')
        self.el6.save()

        self.assertTrue(login_user(self, self.logged_in_user))

        rebuild_index.Command().handle(interactive=False, verbosity=0)
 def setUp(self):
     self.assertTrue(login_user(self, self.user))
Exemplo n.º 40
0
 def setUp(self):
     self.logged_in_user = make_user()
     self.other_user = make_user(userid='other_user',
                                 email='*****@*****.**',
                                 name='Fake2 Fakerly')
     self.assertTrue(login_user(self, self.logged_in_user))
Exemplo n.º 41
0
    def test_join_leave_buttons_work(self):
        #   Create an organisation, a team and a user and assign that
        #   team to that user.
        o = Organisation(name="org0001")
        o.save()
        t = Team(name="team0001", organisation=o)
        t.save()
        u = get_user_model().objects.create_user(userid='*****@*****.**')
        login_user(self, u)

        response = self.app.get(
            reverse(
                'team-detail',
                kwargs={'pk': t.pk}
            )
        )

        form = response.form

        self.assertEqual(
            form.method,
            'post'
        )

        self.assertEqual(
            form.action,
            '/teams/' + str(t.pk) + '/join'
        )

        response = form.submit().follow()

        # Make sure the user is now in the team
        response = self.app.get(
            reverse(
                'user-detail',
                kwargs={'slug': u.slug}
            )
        )

        self.assertTrue(
            response.html.find(
                'a',
                attrs={
                    'class': 'main-list-item',
                    'href': '/teams/' + str(t.pk)
                }
            )
        )

        # Go back to the team detail page so we can submit the link
        response = self.app.get(
            reverse(
                'team-detail',
                kwargs={'pk': t.pk}
            )
        )

        form = response.form

        self.assertEqual(
            form.method,
            'post'
        )

        self.assertEqual(
            form.action,
            '/teams/' + str(t.pk) + '/leave'
        )

        response = form.submit().follow()

        # Make sure the user is no longer in the team
        response = self.app.get(
            reverse(
                'user-detail',
                kwargs={'slug': u.slug}
            )
        )
        self.assertFalse(
            response.html.find(
                'a',
                attrs={
                    'class': 'main-list-item',
                    'href': '/teams/' + str(t.pk)
                }
            )
        )
Exemplo n.º 42
0
 def setUp(self):
     self.assertTrue(login_user(self, self.user))
Exemplo n.º 43
0
def login_user(owner, user):
    return common.login_user(owner, user)
Exemplo n.º 44
0
def login_user(owner, user):
    return common.login_user(owner, user)
Exemplo n.º 45
0
 def setUp(self):
     self.logged_in_user = make_user()
     self.assertTrue(login_user(self, self.logged_in_user))
 def setUp(self):
     self.logged_in_user = make_user()
     self.assertTrue(login_user(self, self.logged_in_user))