Пример #1
0
    def test_get_choice_label_when_label_not_in_choice_list(self):
        choices = [{
            'control': {},
            'name': 'Western Rural',
            'label': 'Western Rural'
        }, {
            'control': {},
            'name': 'Urban',
            'label': 'Urban'
        }, {
            'control': {},
            'name': 'Western Urban',
            'label': 'Western Urban'
        }]
        string = 'Banadir'

        self.assertEqual(get_choice_label(choices, string), [string])

        string = 'Banadir Rural'

        self.assertEqual(get_choice_label(choices, string), [string])

        string = 'Banadir Urban'

        self.assertEqual(get_choice_label(choices, string), [string])
Пример #2
0
    def test_get_choice_label_when_label_not_in_choice_list(self):
        choices = [{
            'control': {},
            'name': 'Western Rural',
            'label': 'Western Rural'
        }, {
            'control': {},
            'name': 'Urban',
            'label': 'Urban'
        }, {
            'control': {},
            'name': 'Western Urban',
            'label': 'Western Urban'
        }]
        string = 'Banadir'

        self.assertEqual(get_choice_label(choices, string), [string])

        string = 'Banadir Rural'

        self.assertEqual(get_choice_label(choices, string), [string])

        string = 'Banadir Urban'

        self.assertEqual(get_choice_label(choices, string), [string])

        string = 200

        self.assertEqual(get_choice_label(choices, string), [])

        string = int(200)

        self.assertEqual(get_choice_label(choices, string), [])
Пример #3
0
    def test_get_choice_label_for_multi_select_with_spaces(self):
        """
        Select Multiple Fields with names with spaces will NEVER match
        their labels
        """
        pam = "PAM"
        croix_rouge = "Croix Rouge"
        both = "Sam Bla"

        choices = [{
            'control': {},
            'name': pam,
            'label': pam
        }, {
            'control': {},
            'name': croix_rouge,
            'label': croix_rouge
        }, {
            'control': {},
            'name': both,
            'label': both
        }, {
            'control': {},
            'name': 'Administration Locale',
            'label': 'Administration Locale'
        }]
        string = "{} {}".format(both, pam)

        self.assertNotIn(both, get_choice_label(choices, string))
Пример #4
0
    def test_get_choice_label_for_multi_select_with_spaces(self):
        """
        Select Multiple Fields with names with spaces will NEVER match
        their labels
        """
        pam = "PAM"
        croix_rouge = "Croix Rouge"
        both = "Sam Bla"

        choices = [{
            'control': {},
            'name': pam,
            'label': pam
        }, {
            'control': {},
            'name': croix_rouge,
            'label': croix_rouge
        }, {
            'control': {},
            'name': both,
            'label': both
        }, {
            'control': {},
            'name': 'Administration Locale',
            'label': 'Administration Locale'
        }]
        string = "{} {}".format(both, pam)

        self.assertNotIn(both, get_choice_label(choices, string))
Пример #5
0
    def test_get_choice_label_with_single_select(self):
        choices = [{
            'control': {},
            'name': 'Western Rural',
            'label': 'Western Rural'
        }, {
            'control': {},
            'name': 'Western Urban',
            'label': 'Western Urban'
        }]
        string = 'Western Rural'

        self.assertEqual(get_choice_label(choices, string), [string])
Пример #6
0
    def test_get_choice_label_with_list_label(self):
        choices = [{
            'control': {},
            'name': 'Western Rural',
            'label': 'Western Rural'
        }, {
            'control': {},
            'name': 'Western Urban',
            'label': 'Western Urban'
        }]
        string = ['Western Rural']

        self.assertEqual(get_choice_label(choices, [string]), [string])
Пример #7
0
    def test_get_choice_label_with_list_label(self):
        choices = [{
            'control': {},
            'name': 'Western Rural',
            'label': 'Western Rural'
        }, {
            'control': {},
            'name': 'Western Urban',
            'label': 'Western Urban'
        }]
        string = ['Western Rural']

        self.assertEqual(get_choice_label(choices, [string]), [string])
Пример #8
0
    def test_get_choice_label_with_single_select(self):
        choices = [{
            'control': {},
            'name': 'Western Rural',
            'label': 'Western Rural'
        }, {
            'control': {},
            'name': 'Western Urban',
            'label': 'Western Urban'
        }]
        string = 'Western Rural'

        self.assertEqual(get_choice_label(choices, string), [string])
Пример #9
0
    def test_get_choice_label_for_multi_select(self):
        pam = "PAM"
        croix_rouge = "Croix Rouge"

        choices = [{
            'control': {},
            'name': '1',
            'label': pam
        }, {
            'control': {},
            'name': '2',
            'label': croix_rouge
        }, {
            'control': {},
            'name': '3',
            'label': 'OXFAM'
        }, {
            'control': {},
            'name': '4',
            'label': 'Administration Locale'
        }]
        string = '1 2'

        self.assertEqual(get_choice_label(choices, string), [pam, croix_rouge])
Пример #10
0
    def test_get_choice_label_for_multi_select(self):
        pam = "PAM"
        croix_rouge = "Croix Rouge"

        choices = [{
            'control': {},
            'name': '1',
            'label': pam
        }, {
            'control': {},
            'name': '2',
            'label': croix_rouge
        }, {
            'control': {},
            'name': '3',
            'label': 'OXFAM'
        }, {
            'control': {},
            'name': '4',
            'label': 'Administration Locale'
        }]
        string = '1 2'

        self.assertEqual(get_choice_label(choices, string), [pam, croix_rouge])