Beispiel #1
0
 def test_location(self):
     request0 = AllocationRequest(project_name="Project X", status="E")
     request0.id = 12345
     site_map = AllocationsSitemap()
     actual_location = site_map.location(request0)
     expected_location = '/allocations/applications/12345/approved'
     self.assertEquals(expected_location, actual_location)
Beispiel #2
0
 def test_apply_for_code_to_summary_for2(self):
     allocation_summary = dict()
     code = '12'
     AllocationRequest.apply_for_code_to_summary(allocation_summary, code)
     self.assertEqual(allocation_summary['for_6'], '12')
     self.assertEqual(allocation_summary['for_4'], '12')
     self.assertEqual(allocation_summary['for_2'], '12')
Beispiel #3
0
 def test_lastmod(self):
     expected_datetime = datetime(2014, 10, 13)
     request0 = AllocationRequest(project_name="Project X", status="E")
     request0.modified_time = expected_datetime
     site_map = AllocationsSitemap()
     actual_modification_datetime = site_map.lastmod(request0)
     self.assertEquals(expected_datetime, actual_modification_datetime)
    def test_partition_active_allocations(self):
        sub_allocations = AllocationRequest.partition_active_allocations()
        self.assertEquals(len(sub_allocations), 3)
        sub_allocations.sort(key=lambda summary: summary['project_name']
                             + str(summary['id']))

        sub_allocation = sub_allocations[0]
        self.assertEquals('qqqqqq.edu.au', sub_allocation['institution'])
        self.assertEquals('USQ eResearch Services Sandbox',
                          sub_allocation['project_name'])
        self.assertEquals('099901', sub_allocation['for_6'])
        self.assertEquals('0999', sub_allocation['for_4'])
        self.assertEquals('09', sub_allocation['for_2'])
        self.assertAlmostEqual(1.2, sub_allocation['instance_quota'], 2)
        self.assertAlmostEqual(2.4, sub_allocation['core_quota'], 2)

        sub_allocation = sub_allocations[1]
        self.assertEquals('qqqqqq.edu.au', sub_allocation['institution'])
        self.assertEquals('USQ eResearch Services Sandbox',
                          sub_allocation['project_name'])
        self.assertEquals('070104', sub_allocation['for_6'])
        self.assertEquals('0701', sub_allocation['for_4'])
        self.assertEquals('07', sub_allocation['for_2'])
        self.assertAlmostEqual(0.8, sub_allocation['instance_quota'], 2)
        self.assertAlmostEqual(1.6, sub_allocation['core_quota'], 2)

        sub_allocation = sub_allocations[2]
        self.assertEquals('gggg.edu.au', sub_allocation['institution'])
        self.assertEquals('UoM_Trajectory_Inference_Attacks',
                          sub_allocation['project_name'])
        self.assertEquals('080109', sub_allocation['for_6'])
        self.assertEquals('0801', sub_allocation['for_4'])
        self.assertEquals('08', sub_allocation['for_2'])
        self.assertAlmostEqual(30.0, sub_allocation['instance_quota'], 2)
        self.assertAlmostEqual(30.0, sub_allocation['core_quota'], 2)
Beispiel #5
0
 def test_strip_email_group_translates_selection(self):
     file_name = path_for_tests("institution_cleaning.json")
     with open(file_name) as institutions_file:
         institutions = json.load(institutions_file)
     for institution in institutions:
         self.assertEqual(AllocationRequest.strip_email_sub_domains(
             institution['original']),
             institution['processed'])
 def test_find_active_allocations_excluding_3_null_fors(self):
     request0 = AllocationRequest(project_name='Project0', status='A')
     request0.field_of_research_1 = None
     request0.field_of_research_2 = None
     request0.field_of_research_3 = None
     request0.save()
     allocations = AllocationRequest.find_active_allocations()
     self.assertEquals(2, len(allocations))
 def test_find_active_allocations_including_new_requests(self):
     request0 = AllocationRequest(project_name='Project0', status='A')
     request0.field_of_research_1 = '11'
     request0.field_of_research_2 = '22'
     request0.field_of_research_3 = '33'
     request0.save()
     allocations = AllocationRequest.find_active_allocations()
     self.assertEquals(3, len(allocations))
    def test_get_all_for_project_with_privacy(self):
        AllocationRequest.show_private_fields = False
        request_id = 1654
        project_allocations = AllocationRequest.get_all_for_project(request_id)

        self.assertEquals(1, len(project_allocations))
        self.assertEquals('UoM_Trajectory_Inference_Attacks',
                          project_allocations[0]['project_name'])
        self.assertEquals('2014-01-06', project_allocations[0]['start_date'])
        self.assertEquals('2014-01-31', project_allocations[0]['end_date'])
        self.assertFalse('use_case' in project_allocations[0])
        self.assertFalse('usage_patterns' in project_allocations[0])
    def test_organise_allocations_tree(self):
        allocations_tree = AllocationRequest.organise_allocations_tree()
        self.assertEquals(3, len(allocations_tree))

        self.assertEquals('USQ eResearch Services Sandbox',
                          allocations_tree['09']['0999']
                          ['099901'][0]['projectName'])
        self.assertEquals('USQ eResearch Services Sandbox',
                          allocations_tree['07']['0701']
                          ['070104'][0]['projectName'])
        self.assertEquals('UoM_Trajectory_Inference_Attacks',
                          allocations_tree['08']['0801']
                          ['080109'][0]['projectName'])
    def test_get_all_for_project(self):
        AllocationRequest.show_private_fields = True
        request_id = 1654
        project_allocations = AllocationRequest.get_all_for_project(request_id)

        self.assertEquals(1, len(project_allocations))
        self.assertEquals('UoM_Trajectory_Inference_Attacks',
                          project_allocations[0]['project_name'])
        self.assertEquals('2014-01-06', project_allocations[0]['start_date'])
        self.assertEquals('2014-01-31', project_allocations[0]['end_date'])
        expected_usecase = "In this project, an algorithm has been " \
            "developed to infer a persons road trajectory " \
            "using POI information sent to a LBS such as " \
            "Google Maps.\r\n\r\n Please contact [XXXX]."
        self.assertEquals(expected_usecase, project_allocations[0]['use_case'])
        self.assertEquals('Data is stored on a remote server so no storage '
                          'is needed. Please contact [XXXX].',
                          project_allocations[0]['usage_patterns'])
Beispiel #11
0
 def items(self):
     return AllocationRequest.find_active_allocations()
Beispiel #12
0
 def test_is_valid_for_none_null(self):
     self.assertTrue(AllocationRequest.is_valid_for_code('00'))
Beispiel #13
0
 def test_is_valid_for_null(self):
     self.assertFalse(AllocationRequest.is_valid_for_code(None))
Beispiel #14
0
 def test_strip_email_group_noprefix(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('uon.edu.au'),
         'uon.edu.au')
Beispiel #15
0
 def test_strip_email_group_prefix_studentmail(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'studentmail.newcastle.edu.au'),
         'newcastle.edu.au')
Beispiel #16
0
 def test_strip_email_group_prefix_unknown(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'unkown.murdoch.edu.au'),
         'unkown.murdoch.edu.au')
Beispiel #17
0
 def test_redact_one_email_with_bracket(self):
     self.assertEqual(AllocationRequest.redact_all_emails(
         'Please contact [email protected])'),
         'Please contact [XXXX])')
Beispiel #18
0
 def test_strip_email_group_prefix_ems(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('ems.rmit.edu.au'),
         'rmit.edu.au')
Beispiel #19
0
 def test_strip_email_group_translates_domain_griffith(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'griffithuni.edu.au'),
         'griffith.edu.au')
Beispiel #20
0
 def test_strip_email_group_noprefix(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'uon.edu.au'),
         'uon.edu.au')
Beispiel #21
0
 def test_strip_email_group_prefix_groupwise(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'groupwise.swin.edu.au'),
         'swin.edu.au')
Beispiel #22
0
 def test_strip_email_group_prefix_ems(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'ems.rmit.edu.au'),
         'rmit.edu.au')
Beispiel #23
0
 def test_strip_email_group_prefix_my(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'my.jcu.edu.au'),
         'jcu.edu.au')
Beispiel #24
0
 def test_redact_no_emails(self):
     self.assertEqual(AllocationRequest.redact_all_emails(
         'Please contact someone for more information'),
         'Please contact someone for more information')
Beispiel #25
0
 def test_redact_one_email(self):
     self.assertEqual(AllocationRequest.redact_all_emails(
         'Please contact [email protected] for more information'),
         'Please contact [XXXX] for more information')
Beispiel #26
0
 def test_strip_email_group_translates_domain_myune(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'myune.edu.au'),
         'une.edu.au')
Beispiel #27
0
 def test_redact_two_emails_in_field(self):
     self.assertEqual(AllocationRequest.redact_all_emails(
         'Please contact [email protected] '
         'or [email protected] for more information'),
         'Please contact [XXXX] '
         'or [XXXX] for more information')
Beispiel #28
0
 def test_strip_email_group_prefix_my(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('my.jcu.edu.au'),
         'jcu.edu.au')
Beispiel #29
0
 def test_strip_email_group_prefix_student(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'student.murdoch.edu.au'),
         'murdoch.edu.au')
Beispiel #30
0
 def test_extract_email_domain(self):
     self.assertEqual(AllocationRequest.extract_email_domain(
         '*****@*****.**'),
         'myune.edu.au')
Beispiel #31
0
 def test_strip_email_group_translates_domain_uwa(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'waimr.uwa.edu.au'),
         'uwa.edu.au')
Beispiel #32
0
 def test_strip_email_group_prefix_groupwise(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('groupwise.swin.edu.au'),
         'swin.edu.au')
Beispiel #33
0
def allocation_tree(request):
    allocation_dict = AllocationRequest.restructure_allocations_tree()
    json_string = dumps(allocation_dict)
    return HttpResponse(json_string, "application/json")
Beispiel #34
0
 def test_strip_email_group_translates_domain_usydney(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'usyd.edu.au'),
         'sydney.edu.au')