Example #1
0
        def test_refresh(self):
            """ Refresh shouldnt throw exceptions """
            self.dp.refresh()
            self.dp.finish(False, False, False)

        def test_finish(self):
            """ Should be able to call finish on cold """
            self.dp.finish(False, False, False)

        def test_get_num_items(self):
            """ Number of items in a fresh dataprovider should be 0 """
            self.dp.refresh()
            assert self.dp.get_num_items() == 0

    return TestDataprovider


# Generate TestCase objects for each dataprovider wrapper
self = soup.get_module(__name__)
for wrapper in ModuleLoader.get_all():
    if wrapper.is_twoway():
        testklass = make_testcase(wrapper)
        setattr(self, testklass.name(), testklass)


# Allow people to run the test case directly
if __name__ == "__main__":
    import unittest
    unittest.main()
            self.pair.sync(block=True)
            self.check_state(0)

        def test_add_sink_delete_sink(self):
            """ should be able to add data at sink, sync, delete at sink, then sync """
            self.test_add_to_sink()
            self.sink.delete_all()
            self.pair.sync(block=True)
            self.check_state(0)

    return TestSynchronization


# Generate all the variations of TestSynchronization
self = soup.get_module(__name__)
mods = ModuleLoader.get_all()
for i in range(len(mods)):
    for j in range(len(mods)):
        source = mods[i]
        sink = mods[j]

        # Cludge: If we have 2 different datatypes, we implicity use a wrapper
        # that converts from the most specialized to the lease specialized datatype.
        # That way we have Contact files instead of Mp3 files etc.
        if source.dataclass == sink.dataclass:
            source_data = source.dataclass
            sink_data = sink.dataclass
        #elif source.dataclass.is_compatible(sink.dataclass.get_datatype():
        #    source_data = source.dataclass
        #    sink_data = # conversion thingy here
        #elif sink.dataclass.is_compatible(source.dataclass.get_datatype()):