Ejemplo n.º 1
0
class TestUpgrade:
    @pytest.fixture(
        params=pathlib.Path(resourceLocation("old_pickles")).glob("*.pkl"),
        scope="class",
        ids=operator.attrgetter("name"),
    )
    def previous_obj_pkl(self, request):
        """Load each pickle to memory once, then run all tests against it.

        Test implementations _must not_ modify the ``previous_obj_pkl`` which
        they are passed, as that will affect tests that run after them.
        """
        return _pkl_load(str(request.param))

    def test_networking_set_on_distro(self, previous_obj_pkl):
        """We always expect to have ``.networking`` on ``Distro`` objects."""
        assert previous_obj_pkl.distro.networking is not None

    def test_blacklist_drivers_set_on_networking(self, previous_obj_pkl):
        """We always expect Networking.blacklist_drivers to be initialised."""
        assert previous_obj_pkl.distro.networking.blacklist_drivers is None

    def test_paths_has_run_dir_attribute(self, previous_obj_pkl):
        assert previous_obj_pkl.paths.run_dir is not None

    def test_vendordata_exists(self, previous_obj_pkl):
        assert previous_obj_pkl.vendordata2 is None
        assert previous_obj_pkl.vendordata2_raw is None
Ejemplo n.º 2
0
 def _load_merge_files(self):
     merge_root = helpers.resourceLocation('merge_sources')
     tests = []
     source_ids = collections.defaultdict(list)
     expected_files = {}
     for fn in glob.glob(os.path.join(merge_root, SOURCE_PAT)):
         base_fn = os.path.basename(fn)
         file_id = re.match(r"source(\d+)\-(\d+)[.]yaml", base_fn)
         if not file_id:
             raise IOError("File %s does not have a numeric identifier"
                           % (fn))
         file_id = int(file_id.group(1))
         source_ids[file_id].append(fn)
         expected_fn = os.path.join(merge_root, EXPECTED_PAT % (file_id))
         if not os.path.isfile(expected_fn):
             raise IOError("No expected file found at %s" % (expected_fn))
         expected_files[file_id] = expected_fn
     for i in sorted(source_ids.keys()):
         source_file_contents = []
         for fn in sorted(source_ids[i]):
             source_file_contents.append([fn, util.load_file(fn)])
         expected = util.load_yaml(util.load_file(expected_files[i]))
         entry = [source_file_contents, [expected, expected_files[i]]]
         tests.append(entry)
     return tests