Exemplo n.º 1
0
    def test_insufficient_information(self):
        test_i_i = _input_producer([
            [1, 1, 'R'],
            [2, 2, 'I'],
            [3, 3, 'T']
        ])

        self.assertIsNone(tf(test_i_i, 2, 'R'))
        self.assertIsNone(tf(test_i_i, 2, 'I'))
        self.assertIsNone(tf(test_i_i, 2, 'T'))

        test_i_i = _input_producer([
            [1, 1, 'R'],
            [2, 2, 'R'],
            [3, 3, 'I']
        ])

        self.assertIsNone(tf(test_i_i, 3, 'R'))

        test_i_i = _input_producer([
            [1, 1, 'I'],
            [2, 2, 'I'],
            [3, 3, 'I']
        ])

        self.assertIsNone(tf(test_i_i, 1, 'R'))
Exemplo n.º 2
0
    def test_unequivocal_choice(self):
        test_u_c = _input_producer([
            [1, 1, 'R'],
            [2, 2, 'I'],
            [3, 3, 'T']
        ])

        test_u_c_R = tf(test_u_c, 1, 'R')
        test_u_c_I = tf(test_u_c, 1, 'I')
        test_u_c_T = tf(test_u_c, 1, 'T')

        self.assertEqual(len(test_u_c_R), 1)
        self.assertEqual(len(test_u_c_R), 1)
        self.assertEqual(len(test_u_c_R), 1)

        self.assertDictEqual(test_u_c_R[0], _input_producer([[1, 1, 'R']])[0])
        self.assertDictEqual(test_u_c_I[0], _input_producer([[2, 2, 'I']])[0])
        self.assertDictEqual(test_u_c_T[0], _input_producer([[3, 3, 'T']])[0])
Exemplo n.º 3
0
    def test_ambiguity_choice(self):
        test_a_c = _input_producer([
            [1, 2, 'R'],
            [2, 2, 'R'],
            [3, 2, 'R']
        ])

        test_pull = [tf(test_a_c, 2, 'R') for _ in range(100)]

        test_pull_1 = [item[0]['advertiser_id'] == 1 for item in test_pull]
        test_pull_2 = [item[0]['advertiser_id'] == 2 for item in test_pull]
        test_pull_3 = [item[0]['advertiser_id'] == 3 for item in test_pull]

        self.assertFalse(all(test_pull_1))
        self.assertFalse(all(test_pull_2))
        self.assertFalse(all(test_pull_3))
Exemplo n.º 4
0
    def test_country_correctness(self):
        test_c_c = _input_producer([
            [1, 5, 'T'],
            [1, 5, 'R'],
            [2, 4, 'R'],
            [2, 4, 'I'],
            [2, 3, 'R'],
            [3, 3, None],
            [4, 1, None]
        ])

        test_pull = tf(test_c_c, 4, 'R')

        self.assertEqual(len(test_pull), 4)

        for item in test_pull:
            country = item['country']
            self.assertTrue(country is None or country == 'R')
Exemplo n.º 5
0
    def test_unique_advertiser_ids(self):
        test_u_a_i = _input_producer([
            [1, 5, 'R'],
            [1, 5, 'R'],
            [2, 4, 'R'],
            [2, 4, 'R'],
            [3, 3, 'R'],
            [3, 3, 'R']
        ])

        test_pull = tf(test_u_a_i, 3, 'R')

        test_ids_pull = []

        for item in test_pull:
            ids = item['advertiser_id']
            self.assertNotIn(ids, test_ids_pull)
            test_ids_pull.append(ids)
Exemplo n.º 6
0
 def test_empty_creatives(self):
     self.assertIsNone(tf([], 0))
     self.assertIsNone(tf([], 5))
     self.assertIsNone(tf([], 5, 'R'))
     self.assertIsNone(tf([], 0, 'R'))