Beispiel #1
0
    def test_build_attributions_json(self):
        attrib_list = attribution_json._compute_list()
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attrib_tutor_1 = next(
            (attrib for attrib in attrib_list
             if attrib['global_id'] == self.tutor_1.person.global_id), None)
        self.assertTrue(attrib_tutor_1)
        self.assertEqual(len(attrib_tutor_1['attributions']), 2)

        #Check if attribution is correct
        attrib_tutor_2 = next(
            (attrib for attrib in attrib_list
             if attrib['global_id'] == self.tutor_2.person.global_id), None)
        self.assertTrue(attrib_tutor_2)
        self.assertEqual(len(attrib_tutor_2['attributions']), 1)
        self.assertEqual(attrib_tutor_2['attributions'][0]['acronym'],
                         "LBIR1210B")
        self.assertEqual(attrib_tutor_2['attributions'][0]['function'],
                         function.CO_HOLDER)
        self.assertEqual(
            attrib_tutor_2['attributions'][0][
                learning_component_year_type.LECTURING], "7.5")
        self.assertRaises(
            KeyError, lambda: attrib_tutor_2['attributions'][0][
                learning_component_year_type.PRACTICAL_EXERCISES + '_CHARGE'])
    def test_with_specific_global_id(self):
        global_id = self.tutor_2.person.global_id
        attrib_list = attribution_json._compute_list(global_ids=[global_id])
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 1)

        attrib_tutor_2 = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == global_id),
            None
        )
        self.assertEqual(len(attrib_tutor_2['attributions']), 1)
Beispiel #3
0
    def test_with_specific_global_id(self):
        global_id = self.tutor_2.person.global_id
        attrib_list = attribution_json._compute_list(global_ids=[global_id])
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 1)

        attrib_tutor_2 = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == global_id),
            None
        )
        self.assertEqual(len(attrib_tutor_2['attributions']), 1)
    def test_with_multiple_global_id(self):
        global_id = self.tutor_2.person.global_id
        global_id_with_no_attributions = "4598989898"
        attrib_list = attribution_json._compute_list(global_ids=[global_id, global_id_with_no_attributions])
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attribution_data = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == global_id_with_no_attributions),
            None
        )
        self.assertFalse(attribution_data['attributions'])
Beispiel #5
0
    def test_with_multiple_global_id(self):
        global_id = self.tutor_2.person.global_id
        global_id_with_no_attributions = "4598989898"
        attrib_list = attribution_json._compute_list(global_ids=[global_id, global_id_with_no_attributions])
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attribution_data = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == global_id_with_no_attributions),
            None
        )
        self.assertFalse(attribution_data['attributions'])
    def test_two_attribution_function_to_same_learning_unit(self):
        new_attrib = AttributionNewFactory(learning_container_year=self.l_container, tutor=self.tutor_1,
                                           function=function.COORDINATOR)
        _create_attribution_charge(self.academic_year, new_attrib, "LBIR1210", Decimal(0), Decimal(0))
        attrib_list = attribution_json._compute_list()
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attrib_tutor_1 = next(
                 (attrib for attrib in attrib_list if attrib['global_id'] == self.tutor_1.person.global_id),
                  None
        )
        self.assertEqual(len(attrib_tutor_1['attributions']), 3)
    def test_learning_unit_in_charge_false(self):
        self.l_container.in_charge = False
        self.l_container.save()

        attrib_list = attribution_json._compute_list()
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attrib_tutor_1 = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == self.tutor_1.person.global_id),
            None)
        self.assertTrue(attrib_tutor_1)
        self.assertEqual(len(attrib_tutor_1['attributions']), 0)
Beispiel #8
0
    def test_learning_unit_in_charge_false(self):
        self.l_container.in_charge = False
        self.l_container.save()

        attrib_list = attribution_json._compute_list()
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attrib_tutor_1 = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == self.tutor_1.person.global_id),
            None)
        self.assertTrue(attrib_tutor_1)
        self.assertEqual(len(attrib_tutor_1['attributions']), 0)
Beispiel #9
0
    def test_two_attribution_function_to_same_learning_unit(self):
        new_attrib = AttributionNewFactory(learning_container_year=self.l_container, tutor=self.tutor_1,
                                           function=function.COORDINATOR)
        _create_attribution_charge(self.academic_year, new_attrib, "LBIR1210", Decimal(0), Decimal(0))
        attrib_list = attribution_json._compute_list()
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attrib_tutor_1 = next(
                 (attrib for attrib in attrib_list if attrib['global_id'] == self.tutor_1.person.global_id),
                  None
        )
        self.assertEqual(len(attrib_tutor_1['attributions']), 3)
Beispiel #10
0
    def test_build_attributions_json(self):
        attrib_list = attribution_json._compute_list()
        self.assertIsInstance(attrib_list, list)
        self.assertEqual(len(attrib_list), 2)

        attrib_tutor_1 = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == self.tutor_1.person.global_id),
            None)
        self.assertTrue(attrib_tutor_1)
        self.assertEqual(len(attrib_tutor_1['attributions']), 2)

        #Check if attribution is correct
        attrib_tutor_2 = next(
            (attrib for attrib in attrib_list if attrib['global_id'] == self.tutor_2.person.global_id),
            None)
        self.assertTrue(attrib_tutor_2)
        self.assertEqual(len(attrib_tutor_2['attributions']), 1)
        self.assertEqual(attrib_tutor_2['attributions'][0]['acronym'], "LBIR1210B")
        self.assertEqual(attrib_tutor_2['attributions'][0]['function'], function.CO_HOLDER)
        self.assertEqual(attrib_tutor_2['attributions'][0][learning_component_year_type.LECTURING], "7.5")
        self.assertRaises(KeyError, lambda: attrib_tutor_2['attributions'][0][learning_component_year_type.PRACTICAL_EXERCISES + '_CHARGE'])