Esempio n. 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)
Esempio n. 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')
Esempio n. 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)
Esempio n. 4
0
    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)
Esempio n. 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'])
Esempio n. 6
0
 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))
Esempio n. 7
0
 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))
Esempio n. 8
0
    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])
Esempio n. 9
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'])
Esempio n. 10
0
    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'])
Esempio n. 11
0
 def items(self):
     return AllocationRequest.find_active_allocations()
Esempio n. 12
0
 def test_is_valid_for_none_null(self):
     self.assertTrue(AllocationRequest.is_valid_for_code('00'))
Esempio n. 13
0
 def test_is_valid_for_null(self):
     self.assertFalse(AllocationRequest.is_valid_for_code(None))
Esempio n. 14
0
 def test_strip_email_group_noprefix(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('uon.edu.au'),
         'uon.edu.au')
Esempio n. 15
0
 def test_strip_email_group_prefix_studentmail(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'studentmail.newcastle.edu.au'),
         'newcastle.edu.au')
Esempio n. 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')
Esempio n. 17
0
 def test_redact_one_email_with_bracket(self):
     self.assertEqual(AllocationRequest.redact_all_emails(
         'Please contact [email protected])'),
         'Please contact [XXXX])')
Esempio n. 18
0
 def test_strip_email_group_prefix_ems(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('ems.rmit.edu.au'),
         'rmit.edu.au')
Esempio n. 19
0
 def test_strip_email_group_translates_domain_griffith(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'griffithuni.edu.au'),
         'griffith.edu.au')
Esempio n. 20
0
 def test_strip_email_group_noprefix(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'uon.edu.au'),
         'uon.edu.au')
Esempio n. 21
0
 def test_strip_email_group_prefix_groupwise(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'groupwise.swin.edu.au'),
         'swin.edu.au')
Esempio n. 22
0
 def test_strip_email_group_prefix_ems(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'ems.rmit.edu.au'),
         'rmit.edu.au')
Esempio n. 23
0
 def test_strip_email_group_prefix_my(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'my.jcu.edu.au'),
         'jcu.edu.au')
Esempio n. 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')
Esempio n. 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')
Esempio n. 26
0
 def test_strip_email_group_translates_domain_myune(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'myune.edu.au'),
         'une.edu.au')
Esempio n. 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')
Esempio n. 28
0
 def test_strip_email_group_prefix_my(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('my.jcu.edu.au'),
         'jcu.edu.au')
Esempio n. 29
0
 def test_strip_email_group_prefix_student(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'student.murdoch.edu.au'),
         'murdoch.edu.au')
Esempio n. 30
0
 def test_extract_email_domain(self):
     self.assertEqual(AllocationRequest.extract_email_domain(
         '*****@*****.**'),
         'myune.edu.au')
Esempio n. 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')
Esempio n. 32
0
 def test_strip_email_group_prefix_groupwise(self):
     self.assertEqual(
         AllocationRequest.strip_email_sub_domains('groupwise.swin.edu.au'),
         'swin.edu.au')
Esempio n. 33
0
def allocation_tree(request):
    allocation_dict = AllocationRequest.restructure_allocations_tree()
    json_string = dumps(allocation_dict)
    return HttpResponse(json_string, "application/json")
Esempio n. 34
0
 def test_strip_email_group_translates_domain_usydney(self):
     self.assertEqual(AllocationRequest.strip_email_sub_domains(
         'usyd.edu.au'),
         'sydney.edu.au')