def test_get_primary_and_secondary_key(self):
     """ Test for fetching the objects stored in the TwoKeyDict """
     triplets = [(uuid.uuid4(), uuid.uuid4(), uuid.uuid4())
                 for a in xrange(10)]
     tw_dict = TwoKeyDict(*triplets)
     for triplet in triplets:
         self.assertEqual(tw_dict._get_secondary_key(triplet[0]),
                          triplet[1])
         self.assertEqual(tw_dict._get_primary_key(triplet[1]), triplet[0])
Example #2
0
 def test_get_primary_and_secondary_key(self):
     """ Test for fetching the objects stored in the TwoKeyDict """
     triplets = [(uuid.uuid4(), uuid.uuid4(), uuid.uuid4())
                 for a in range(10)]
     tw_dict = TwoKeyDict(*triplets)
     for triplet in triplets:
         self.assertEqual(tw_dict._get_secondary_key(triplet[0]),
                          triplet[1])
         self.assertEqual(tw_dict._get_primary_key(triplet[1]),
                          triplet[0])
Example #3
0
    def test_missing_and_then_add(self):
        # Primary
        local_id = '3ea957cb-417f-4944-be6c-02a1b0a84bd2'
        # Secondary
        remote_id = 'https://api.launchpad.net/1.0/bugs/345808'
        value = "Hello world"

        tw_dict = TwoKeyDict()
        self.assertRaises(KeyError, tw_dict._get_secondary_key, remote_id)
        tw_dict.add((local_id, remote_id, value))
        self.assertEqual(remote_id, tw_dict._get_secondary_key(local_id))
Example #4
0
    def test_missing_and_then_add(self):
        # Primary
        local_id = '3ea957cb-417f-4944-be6c-02a1b0a84bd2'
        # Secondary
        remote_id = 'https://api.launchpad.net/1.0/bugs/345808'
        value = "Hello world"

        tw_dict = TwoKeyDict()
        self.assertRaises(KeyError, tw_dict._get_secondary_key, remote_id)
        tw_dict.add((local_id, remote_id, value))
        self.assertEqual(remote_id, tw_dict._get_secondary_key(local_id))