Beispiel #1
0
    def test_log_contains_all_records(self):
        """
        We have added two records, one each for leader and admin.
        This functions asserts if the log file contains two records.
        To make it more comprehensive, after the initial assertion,
        another record is add to the log and the number of records
        are tested once again.

        It calls the previous two methods so the logs are within the same
        execution context.
        :return:
        """
        self.Test_log_contains_info_member()
        self.Test_log_contains_warning_leader()

        p = Project.objects.get(name__exact='Hell')

        f = open(p.activitylog.content, 'r')
        logfile = f.readlines()
        number_of_lines = len(logfile)
        TestCase.assertEquals(self, number_of_lines, 2)
        f.close()
        os.remove(p.activitylog.content)
        s = '/'.join(p.activitylog.content.split('/')[:-1])
        os.rmdir(s)
Beispiel #2
0
 def Test_log_contains_info_member(self):
     m = MemberUser.objects.get(first_name__exact='Heracles')
     p = m.project
     log('INFO', m, 'test content')
     f = open(p.activitylog.content, 'r')
     logfile = f.readlines()[0]
     data = parse('[{}] [{}] [{}] [{}] [{}] [{}]', logfile)
     TestCase.assertEquals(self, data[0], 'INFO')
     TestCase.assertEquals(self, data[1], m.get_full_name())
     TestCase.assertEquals(self, data[2], 'MEMBER')
     TestCase.assertEquals(self, data[3], m.project.name)
     TestCase.assertEquals(self, data[5], 'test content')
     f.flush()
     f.close()
Beispiel #3
0
 def Test_log_contains_warning_leader(self):
     l = LeaderUser.objects.get(first_name__exact='leader')
     p = l.project
     log('WARNING', l, 'leader log record')
     f = open(p.activitylog.content, 'r')
     logfile = f.readlines()[1]
     data = parse('[{}] [{}] [{}] [{}] [{}] [{}]', logfile)
     TestCase.assertEquals(self, data[0], 'WARNING')
     TestCase.assertEquals(self, data[1], l.get_full_name())
     TestCase.assertEquals(self, data[2], 'LEADER')
     TestCase.assertEquals(self, data[3], l.project.name)
     TestCase.assertEquals(self, data[5], 'leader log record')
     f.flush()
     f.close()
Beispiel #4
0
def assertRecordMetadataEqual(serialized, record_metadata_instance):
    t = TestCase()
    t.assertDictEqual(serialized['json'], record_metadata_instance.json)
    t.assertEquals(serialized['id'], str(record_metadata_instance.id))
    t.assertEquals(serialized['created'].split('Z')[0],
                   record_metadata_instance.created.isoformat().split('+')[0])
    t.assertEquals(serialized['updated'].split('Z')[0],
                   record_metadata_instance.updated.isoformat().split('+')[0])
    t.assertEquals(serialized['version_id'],
                   record_metadata_instance.version_id)
 def test_first(self):
     bdg = Budget.objects.all()
     bdgt1 = bdg[0]
     bdgt2 = bdg[1]
     TestCase.assertEquals(self, bdgt1.total, 0)
     TestCase.assertEquals(self, bdgt2.total, 0)
     stf = StaffCost.objects.filter(id_budget=bdgt1).order_by('cost').reverse().first()
     TestCase.assertEquals(self, stf.cost, 15)
Beispiel #6
0
def test_response_is_landing_page(test_case: TestCase, response: Response):
    test_case.assertEquals(response.status_code, 200)
    test_case.assertEquals(response.request['PATH_INFO'], "/")
Beispiel #7
0
def test_response_is_login_page(test_case: TestCase, response: Response):
    test_case.assertEquals(response.status_code, 200)
    test_case.assertTrue("login" in response.request['PATH_INFO'])
Beispiel #8
0
def assertOrcidIdentityEqual(serialized,
                             orcid_identity_instance,
                             has_token=False):
    t = TestCase()
    t.assertEquals(serialized['id'], orcid_identity_instance.id)
    t.assertEquals(serialized['orcid_value'],
                   str(orcid_identity_instance.orcid_value))
    t.assertEquals(serialized['useridentity_user_id'],
                   orcid_identity_instance.useridentity_user_id)
    t.assertEquals(serialized['client_id'],
                   str(orcid_identity_instance.client_id))
    t.assertDictEqual(serialized['extra_data'],
                      orcid_identity_instance.extra_data)
    t.assertEquals(serialized['user'], orcid_identity_instance.user.id)
    if has_token:
        try:
            plain = orcid_identity_instance.remote_token.access_token_plain
        except ObjectDoesNotExist:
            plain = None
        t.assertEquals(serialized['token'], plain)