示例#1
0
    def test_code_rule(self):
        aggreement_dict = create_agreement_dict()

        mock_data = {
            'estimated_value': 100000,
            'entities': Organization.objects.get(id=1),
            'type': 'Construction',
            'code': Code.objects.get(id=1),
            'exceptions': [GeneralException.objects.get(id=1)],
            'limited_tendering': LimitedTenderingReason.objects.get(id=1),
            'cfta_exceptions': [CftaException.objects.get(id=1)]
        }

        agreement = code_rule(aggreement_dict, mock_data)
        true_aggreements = ['ccfta', 'ccofta', 'chfta', 'cpafta', 'cpfta']
        false_aggreements = [
            'ckfta', 'cufta', 'wto_agp', 'ceta', 'cptpp', 'cfta'
        ]

        false_dict = {'code': False}
        empty_dict = {}
        true_dict = {'code': True}

        for k, v in agreement.items():
            if k in true_aggreements:
                self.assertEqual(true_dict, v)
                self.assertFalse(false_dict == v)
                self.assertFalse(empty_dict == v)
            if k in false_aggreements:
                self.assertEqual(false_dict, v)
                self.assertFalse(empty_dict == v)
                self.assertFalse(true_dict == v)
            if (k not in true_aggreements) and (k not in false_aggreements):
                self.assertEqual(1, 2)
示例#2
0
    def test_set_true_all_true(self):
        aggreement_dict = create_agreement_dict()

        agreement = set_true(aggreement_dict, 'code')
        true_aggreements = [
            'ccfta', 'ccofta', 'chfta', 'cpafta', 'cpfta', 'ckfta', 'cufta',
            'wto_agp', 'ceta', 'cptpp', 'cfta'
        ]

        false_dict = {'code': False}
        empty_dict = {}
        true_dict = {'code': True}

        for k, v in agreement.items():
            if k in true_aggreements:
                self.assertEqual(true_dict, v)
                self.assertFalse(false_dict == v)
                self.assertFalse(empty_dict == v)
            if (k not in true_aggreements):
                self.assertEqual(1, 2)
示例#3
0
    def test_create_agreement_dict(self):
        test_dict = create_agreement_dict()

        mock_dict = {
            'ccfta': {},
            'ccofta': {},
            'chfta': {},
            'cpafta': {},
            'cpfta': {},
            'ckfta': {},
            'cufta': {},
            'wto_agp': {},
            'ceta': {},
            'cptpp': {},
            'cfta': {}
        }

        self.assertEqual(test_dict, mock_dict)
        self.assertTrue(test_dict == mock_dict)
        self.assertFalse(test_dict != mock_dict)
示例#4
0
    def test_determine_final_coverage(self):
        agreement_dict = create_agreement_dict()

        mock_data = {
            'estimated_value': 100000,
            'entities': Organization.objects.get(id=1),
            'type': 'Construction',
            'code': Code.objects.get(id=1),
            'exceptions': None,
            'limited_tendering': [LimitedTenderingReason.objects.get(id=1)],
            'cfta_exceptions': None
        }

        agreement_dict = value_threshold_rule(agreement_dict, mock_data)
        agreement_dict = organization_rule(agreement_dict, mock_data)
        agreement_dict = code_rule(agreement_dict, mock_data)

        exception_dict = {
            'exceptions': GeneralException,
            'cfta_exceptions': CftaException,
        }
        agreement_dict = exceptions_rule(agreement_dict, mock_data,
                                         exception_dict)
        check = determine_final_coverage(agreement_dict)

        true_aggreements = ['ccfta', 'ccofta', 'chfta', 'cpafta', 'cpfta']
        false_aggreements = [
            'ckfta', 'cufta', 'wto_agp', 'ceta', 'cptpp', 'cfta'
        ]

        for k, v in check.items():
            if k in true_aggreements:
                self.assertEqual(True, v)
                self.assertFalse(False == v)
                self.assertFalse(None == v)
            if k in false_aggreements:
                self.assertEqual(False, v)
                self.assertFalse(None == v)
                self.assertFalse(True == v)
            if (k not in true_aggreements) and (k not in false_aggreements):
                self.assertEqual(1, 2)
示例#5
0
    def test_value_threshold_rule_true(self):
        aggreement_dict = create_agreement_dict()

        mock_data = {
            'estimated_value': 100000,
            'entities': Organization.objects.get(id=1),
            'type': 'Goods',
            'code': Code.objects.get(id=1),
            'exceptions': GeneralException.objects.get(id=1),
            'limited_tendering': LimitedTenderingReason.objects.get(id=1),
            'cfta_exceptions': CftaException.objects.get(id=1)
        }

        agreement = value_threshold_rule(aggreement_dict, mock_data)
        false_dict = {'estimated_value': False}
        empty_dict = {}
        true_dict = {'estimated_value': True}
        for v in agreement.values():
            self.assertEqual(empty_dict, v)
            self.assertTrue(empty_dict == v)
            self.assertFalse(empty_dict != v)
            self.assertFalse(false_dict == v)
            self.assertFalse(true_dict == v)