Exemple #1
0
 def test_get_location_string_no_city_no_country(self):
     """Does get_location_string() work when there's no city or country?"""
     with testfixtures.Replacer() as r:
         r.replace('stars.apps.institutions.models.Institution.profile',
                   MockProfile(city='', state='ST', country_iso=''))
         institution = InstitutionFactory()
         self.assertEqual(institution.get_location_string(), 'ST')
Exemple #2
0
    def test_user_with_many_stars_accounts(self):
        """Do each of the old paths return 200 if user has > 1 StarsAccount?
        """
        user = User.objects.create_user(username='******', password='******')
        user.save()
        institution1 = InstitutionFactory()
        institution2 = InstitutionFactory()
        StarsAccountFactory(user=user,
                            institution=institution1,
                            user_level='admin',
                            terms_of_service=True)
        submission_set1 = SubmissionSetFactory(institution=institution1)
        institution1.current_submission = submission_set1
        institution1.save()
        StarsAccountFactory(user=user,
                            institution=institution2,
                            user_level='admin',
                            terms_of_service=True)
        submission_set2 = SubmissionSetFactory(institution=institution1)
        institution2.current_submission = submission_set2
        institution2.save()

        test_client = test.client.Client()
        self.assertTrue(
            test_client.login(username=user.username, password='******'))

        for old_path in OLD_PATHS_TO_PRESERVE:
            path = '/' + old_path
            response = test_client.get(path, follow=True)
            self.assertEqual(response.status_code, 200)
Exemple #3
0
 def test_access_level_in_review_mode(self):
     """When a submission is in review mode, is access_level correct?
     """
     institution = InstitutionFactory()
     self.assertEqual(institution.access_level, Subscription.BASIC_ACCESS)
     institution.current_submission = SubmissionSetFactory(
         status=REVIEW_SUBMISSION_STATUS)
     institution.save()
     self.assertEqual(institution.access_level, Subscription.FULL_ACCESS)
Exemple #4
0
 def test_is_participant_in_review_mode(self):
     """When a submission is in review mode, is is_particpant True?
     """
     institution = InstitutionFactory()
     self.assertFalse(institution.is_participant)
     institution.current_submission = SubmissionSetFactory(
         status=REVIEW_SUBMISSION_STATUS)
     institution.save()
     self.assertTrue(institution.is_participant)
Exemple #5
0
 def test_get_particpants_context_sorts_by_country(self):
     """Does get_participants_context sort its result by country?
     """
     InstitutionFactory(country='Bolivia')
     InstitutionFactory(country='Austrailia')
     InstitutionFactory(country='Denmark')
     InstitutionFactory(country='Columbia')
     participants_context = Dashboard().get_participants_context()
     participants = participants_context['participants']
     self.assertEqual(participants.pop()[0], 'Denmark')
     self.assertEqual(participants.pop()[0], 'Columbia')
     self.assertEqual(participants.pop()[0], 'Bolivia')
     self.assertEqual(participants.pop()[0], 'Austrailia')
Exemple #6
0
    def setUp(self):
        super(ValueErrorTest, self).setUp()

        self.institution = InstitutionFactory()
        self.account = StarsAccountFactory(institution=self.institution,
                                           user_level='admin')
        self.request.user = self.account.user

        self.field = DocumentationFieldFactory(type='boolean')
        self.submission = init_submissionset(self.institution,
                                             self.account.user)

        self.field.credit.identifier = u"CR-1"
        self.field.credit.save()
        self.credit = self.field.credit

        self.subcategory = self.credit.subcategory
        self.subcategory.title = u"subcategory"
        self.subcategory.save()

        self.subcategory.category.abbreviation = "CAT"
        self.subcategory.category.save()
        self.category = self.subcategory.category

        self.rp = ResponsiblePartyFactory(institution=self.institution)

        self.view_kwargs = {
            "institution_slug": self.institution.slug,
            "submissionset": str(self.submission.id),
            "category_abbreviation": self.category.abbreviation,
            "subcategory_slug": self.subcategory.slug,
            "credit_identifier": self.credit.identifier
        }
Exemple #7
0
    def setUp(self):
        self.institution_one = InstitutionFactory(name='First One')
        self.institution_two = InstitutionFactory(name='Second One')
        self.institution_three = InstitutionFactory(name='AASHE Test')
        creditset = CreditSetFactory()
        self.submission_one = SubmissionSetFactory(
            institution=self.institution_one, creditset=creditset)
        self.submission_two = SubmissionSetFactory(
            institution=self.institution_two, creditset=creditset)
        self.submission_three = SubmissionSetFactory(
            institution=self.institution_three, creditset=creditset)

        self.filter = Filter(key='institution',
                             title='Name',
                             item_list=(('Yes', 'True'), ('No', 'False')),
                             base_qs=SubmissionSet.objects.all())
Exemple #8
0
 def setUp(self):
     super(InstitutionToolMixinTest, self).setUp()
     self.institution = InstitutionFactory(slug='on-the-beach-soldier')
     self.account = StarsAccountFactory(institution=self.institution)
     self.request.user = self.account.user
     creditset = CreditSetFactory()
     self.submission = SubmissionSetFactory(institution=self.institution,
                                            creditset=creditset)
Exemple #9
0
 def setUp(self):
     """
         Creates some data to show on the page.
         Gives ViewTest.test_get_succeeds a little bit
         more of a work out.
     """
     super(SelectInstitutionViewTest, self).setUp()
     institution = InstitutionFactory()
     stars_account = StarsAccountFactory(institution=institution,
                                         user=UserFactory())
     self.request.user = stars_account.user
Exemple #10
0
 def setUp(self):
     if skip_live_server_tests():
         raise unittest.SkipTest()
     super(StarsLiveServerTest, self).setUp()
     self.plain_text_password = '******'
     self.user = UserFactory(username='******',
                             password=self.plain_text_password)
     self.institution = InstitutionFactory()
     self.stars_account = StarsAccountFactory(user=self.user,
                                              institution=self.institution,
                                              user_level='admin')
     self.login()
Exemple #11
0
 def setUp(self):
     institution = InstitutionFactory()
     self.pending_submission = SubmissionSetFactory(
         institution=institution, status=PENDING_SUBMISSION_STATUS)
     self.processing_submission = SubmissionSetFactory(
         institution=institution, status=PROCESSSING_SUBMISSION_STATUS)
     self.finalized_submission = SubmissionSetFactory(
         institution=institution, status=FINALIZED_SUBMISSION_STATUS)
     self.rated_submission = SubmissionSetFactory(
         institution=institution, status=RATED_SUBMISSION_STATUS)
     self.submissions_for_scorecards = views.get_submissions_for_scorecards(
         institution=institution)
Exemple #12
0
    def setUp(self):
        super(SRT87Test, self).setUp()

        # initialize the creditset and institution
        self.institution = InstitutionFactory()
        self.account = StarsAccountFactory(institution=self.institution,
                                           user_level='admin')
        self.request.user = self.account.user

        self.field = DocumentationFieldFactory(type='numeric',
                                               required=True,
                                               min_range=0)

        # Set up titles for the url
        self.field.credit.identifier = u"CR-1"
        self.field.credit.validation_rules = (
            "if A < 0: errors['B'] = 'you have errors'")
        self.field.credit.save()
        self.credit = self.field.credit

        self.subcategory = self.credit.subcategory
        self.subcategory.title = u"subcategory"
        self.subcategory.save()

        self.subcategory.category.abbreviation = "CAT"
        self.subcategory.category.save()
        self.category = self.subcategory.category

        tabular_field_dict = {
            "numRows": 1,
            "fields": [['']],
            "rowHeadings": ["Row 1"],
            "colHeadings": ["Col 1"],
            "numCols": 1
        }
        self.tabular_field = DocumentationFieldFactory(
            type='tabular',
            required=True,
            tabular_fields=tabular_field_dict,
            credit=self.credit)
        # create a submission set to work with
        self.submission = init_submissionset(self.institution,
                                             self.account.user)

        self.rp = ResponsiblePartyFactory(institution=self.institution)

        self.view_kwargs = {
            "institution_slug": self.institution.slug,
            "submissionset": str(self.submission.id),
            "category_abbreviation": self.category.abbreviation,
            "subcategory_slug": self.subcategory.slug,
            "credit_identifier": self.credit.identifier
        }
Exemple #13
0
    def test_get_ratings_context(self):
        """Does get_ratings_context return a sensible context?
        """
        gold_rating = RatingFactory(name='gold')

        for factory in range(2):
            InstitutionFactory(current_rating=gold_rating,
                               current_submission=SubmissionSetFactory(),
                               rating_expires=datetime.date(2020, 1, 1))

        ratings_context = Dashboard().get_ratings_context()

        self.assertEqual(2, ratings_context['gold'])
Exemple #14
0
    def test_unauthenticated_user(self):
        """Do each of the old paths return 200 if user isn't logged in?
        """
        user = User.objects.create_user(username='******', password='******')
        user.save()
        InstitutionFactory()

        test_client = test.client.Client()

        for old_path in OLD_PATHS_TO_PRESERVE:
            path = '/' + old_path
            response = test_client.get(path, follow=True)
            self.assertEqual(response.status_code, 200)
Exemple #15
0
    def test_user_with_no_stars_account(self):
        """Do each of the old paths return 200 if user has no StarsAccount?
        """
        user = User.objects.create_user(username='******', password='******')
        user.save()
        InstitutionFactory()

        test_client = test.client.Client()
        self.assertTrue(
            test_client.login(username=user.username, password='******'))

        for old_path in OLD_PATHS_TO_PRESERVE:
            path = '/' + old_path
            response = test_client.get(path, follow=True)
            self.assertEqual(response.status_code, 200)
Exemple #16
0
    def setUp(self):

        today = datetime.date.today()
        td = datetime.timedelta(days=1)

        # create 3 rated Institutions
        cs = CreditSetFactory()
        count = 0
        for l in ['a', 'b', 'c', 'd']:
            count += 1
            r = RatingFactory(minimal_score=count, name=l, creditset=cs)
            ss = SubmissionSetFactory(creditset=cs, status='r', rating=r)
            i = InstitutionFactory(is_participant=True,
                                   rated_submission=ss,
                                   current_rating=r)
        # create 1 non-rated Institutions
        for _ in range(1):
            i = InstitutionFactory()
            s = SubscriptionFactory(end_date=today - td)
            i.current_subscription = s
            i.save()
Exemple #17
0
 def setUp(self):
     super(SubmissionSummaryViewTest, self).setUp()
     self.institution = InstitutionFactory()
     self.account = StarsAccountFactory(institution=self.institution)
     self.request.user = self.account.user
     self.submission = SubmissionSetFactory(institution=self.institution)
Exemple #18
0
 def test_get_liaison_name_no_middle_name(self):
     institution = InstitutionFactory(contact_first_name='William',
                                      contact_last_name='Burroughs')
     self.assertEqual(self.view.get_liaison_name(institution),
                      'William Burroughs')
Exemple #19
0
 def setUp(self):
     super(SubmissionSetIsNotLockedMixinTest, self).setUp()
     self.institution = InstitutionFactory(slug='hey-baby-you-look-lonely')
     self.account = StarsAccountFactory(institution=self.institution)
     self.request.user = self.account.user
     self.submission = SubmissionSetFactory(institution=self.institution)
Exemple #20
0
 def setUp(self):
     self.subscription = SubscriptionFactory(
         institution=InstitutionFactory())
     self.member = InstitutionFactory(is_member=True)
     self.nonmember = InstitutionFactory(is_member=False)
Exemple #21
0
 def setUp(self):
     SubmissionSet.objects.all().delete()
     self.institution = InstitutionFactory()