Ejemplo n.º 1
0
def test_project_creator_deserialization(client, project):
    """Check that the correct creator is returned on deserialization."""
    from renku.core.models.provenance.agents import Person

    # modify the project metadata to change the creator
    project = client.project
    project.creator = Person(email='*****@*****.**', name='Johnny Doe')
    project.to_yaml()
    client.repo.git.commit('-a', '--amend', '-C', 'HEAD', '--author',
                           'Johnny Doe <*****@*****.**>', '--no-verify')

    # the project creator should always be the one in the metadata
    assert '*****@*****.**' == client.project.creator.email
    assert 'Johnny Doe' == client.project.creator.name
    assert client.project.creator.label == client.project.creator.name

    # Remove the creator from metadata
    project = client.project
    project.creator = None
    project.to_yaml()
    client.repo.git.commit('-a', '--amend', '-C', 'HEAD', '--author',
                           'Jane Doe <*****@*****.**>', '--no-verify')

    # now the creator should be the one from the commit
    project = Project.from_yaml(client.renku_metadata_path, client=client)
    assert '*****@*****.**' == project.creator.email
    assert 'Jane Doe' == project.creator.name
    assert project.creator.label == project.creator.name
Ejemplo n.º 2
0
    def project(self):
        """Return the Project instance."""
        if self.renku_metadata_path.exists() and self._project is None:
            self._project = Project.from_yaml(self.renku_metadata_path,
                                              client=self)

        return self._project
Ejemplo n.º 3
0
    def with_metadata(self, read_only=False, name=None):
        """Yield an editable metadata object."""
        metadata_path = self.renku_metadata_path

        if metadata_path.exists():
            metadata = Project.from_yaml(metadata_path, client=self)
        else:
            metadata = Project(name=name, client=self)
            metadata.__reference__ = metadata_path

        yield metadata

        if not read_only:
            metadata.to_yaml()
Ejemplo n.º 4
0
 def project(self):
     """Return the Project instance."""
     if self.renku_metadata_path.exists():
         return Project.from_yaml(self.renku_metadata_path, client=self)