Ejemplo n.º 1
0
 def test_get_units(self):
     # Setup
     self.populate()
     # Test
     conduit = ProfilerConduit()
     criteria = UnitAssociationCriteria(type_ids=[self.TYPE_1_DEF.id])
     units = conduit.get_units(self.REPO_ID, criteria)
     # Verify
     self.assertEquals(len(units), 9)
Ejemplo n.º 2
0
 def test_get_bindings(self):
     # Setup
     self.populate()
     # Test
     conduit = ProfilerConduit()
     binds = conduit.get_bindings(self.CONSUMER_ID)
     # Verify
     self.assertEquals(1, len(binds))
     self.assertTrue(binds[0], self.REPO_ID)
Ejemplo n.º 3
0
    def test_get_repo_units_additional_field(self):
        # Setup
        self.populate(additional_key='extra_field')
        # Test
        conduit = ProfilerConduit()
        units = conduit.get_repo_units(self.REPO_ID, content_type_id=self.TYPE_1_DEF.id, 
                                       additional_unit_fields=['extra_field'])

        # Verify that all the units in the repo with given type are returned along with unit_key and extra field
        self.assertEquals(len(units), 9)
        for u in units:
            self.assertTrue('key-1' in u.unit_key)
            self.assertTrue('extra_field' in u.metadata)
Ejemplo n.º 4
0
    def test_get_repo_units(self):
        # Setup
        self.populate()
        # Test
        conduit = ProfilerConduit()
        units1 = conduit.get_repo_units(self.REPO_ID, content_type_id=self.TYPE_1_DEF.id, additional_unit_fields=[])
        units2 = conduit.get_repo_units(self.REPO_ID, content_type_id=self.TYPE_2_DEF.id, additional_unit_fields=[])

        # Verify that all the units in the repo with given type are returned along with unit_key
        self.assertEquals(len(units1), 9)
        for u in units1:
            self.assertTrue('key-1' in u.unit_key)
            self.assertFalse('key-2' in u.unit_key)
        self.assertEquals(len(units2), 9)
        for u in units2:
            self.assertTrue('key-2' in u.unit_key)
            self.assertFalse('key-1' in u.unit_key)