bagit-profiles / bagit-profiles-validator

A simple Python module for validating BagIt Profiles.
The Unlicense
12 stars 6 forks source link

Pass profile to constructor #7

Closed kba closed 5 years ago

kba commented 5 years ago

Adds the possibility to pass the profile as a constructor arg, circumventing fetching via HTTP. The url parameter is still required. Here's the unit test to see what it does:

class BagitProfileConstructorTest(TestCase):
     def setUp(self):
        with open('./bagProfileBar.json', 'rb') as f:
            self.profile_str = f.read().decode('utf-8') if sys.version_info > (3,) else f.read()
        self.profile_dict = json.loads(self.profile_str)
     def test_profile_kwarg(self):
        profile_url = Profile(PROFILE_URL)
        profile_dict = Profile(PROFILE_URL, profile=self.profile_dict)
        profile_str = Profile(PROFILE_URL, profile=self.profile_str)
        self.assertEqual(json.dumps(profile_url.profile), json.dumps(profile_dict.profile))
        self.assertEqual(json.dumps(profile_str.profile), json.dumps(profile_dict.profile))

We need to run many processes to quickly check profile adherence and running the same HTTP request over and over seems wasteful. When testing, it's also easier to pass a local profile. But we still need to verify that the BagIt-Profile-Identifier matches.

(blocked by #5)

ruebot commented 5 years ago

@kba, we have #5 merged now. Let me know the order you'd like to move forward with the outstanding PRs.

kba commented 5 years ago

Hi, thanks. I merged master into #8 and rebased the other PRs against #8, so a sensible order would be:

If you are okay with all of these and don't want to resolve conflicts, feel free to merge my dev branch into master, it contains these commits and will mark all the PR as merged.

ruebot commented 5 years ago

Let's do them separate, so we have commits for each.

kba commented 5 years ago

Let's do them separate, so we have commits for each.

They are still separate commits, it just has the branches merged with conflicts resolved.

ruebot commented 5 years ago

Oh, I mean squashed commits for each unit of work in the pull requests.