コード例 #1
0
ファイル: test_utilities.py プロジェクト: anderstheet/scrunch
    def test_get_project_nested(self, mocked_get_child, session):

        shoji_entity = {
            "element": "shoji:catalog",
            "body": {
                "name": "Y Team",
                "id": "614a7b2ebe9a4292bba54edce83563ae"
            },
            "index": {
                "9165e5f4eb004bb4b257a90645bfb968": {
                    "name": "California",
                    "id": "9165e5f4eb004bb4b257a90645bfb968",
                    "type": "project"
                }
            }
        }

        site_mock = mock.MagicMock(**shoji_entity)
        site_mock.entity = mock.MagicMock(**shoji_entity)
        session.projects.by.side_effect = _by_side_effect(
            shoji_entity, site_mock)

        project = get_project('Y Team|California')
        assert isinstance(project, Project)
        assert str(project) == 'California'
        mocked_get_child.assert_called_with('California')
コード例 #2
0
ファイル: test_utilities.py プロジェクト: AlasdairE/scrunch
    def test_get_project_by_id(self, session):

        shoji_entity = {
            "element": "shoji:catalog",
            "body": {
                "name": "Y Team",
                "id": "614a7b2ebe9a4292bba54edce83563ae"
            }
        }

        site_mock = mock.MagicMock(**shoji_entity)
        site_mock.entity = mock.MagicMock(**shoji_entity)
        session.projects.by.side_effect = _by_side_effect(shoji_entity, site_mock)

        project = get_project('614a7b2ebe9a4292bba54edce83563ae')
        session.projects.by.assert_called_with('id')
        assert isinstance(project, Project)

        with pytest.raises(KeyError) as excinfo:
            get_project('invalidid')
        assert str(excinfo.value) == \
               "'Project (name or id: invalidid) not found.'"
コード例 #3
0
ファイル: test_projects.py プロジェクト: AlasdairE/scrunch
    def test_move_dataset(self):
        fo = get_user(username2)
        fo_site = connect(fo.email, password2, HOST)

        # These two datasets are created by the default logged user
        _ds1 = site.datasets.create(
            shoji_entity_wrapper({'name': 'test_move_dataset1'})).refresh()
        _ds2 = site.datasets.create(
            shoji_entity_wrapper({'name': 'test_move_dataset2'})).refresh()

        # This dataset is created and owned by the other user
        _ds4 = fo_site.datasets.create(
            shoji_entity_wrapper({
                'name': 'test_move_dataset4',
                'owner': fo.url
            })).refresh()

        ds1 = get_dataset(_ds1.body.id)
        ds2 = get_dataset(_ds2.body.id)
        ds4 = get_dataset(_ds4.body.id, connection=fo_site)

        ds2.add_user(fo, edit=True)

        # Create a hierarchy A -> B
        pa = new_project("test_move_dataset_A")
        pa.move_here([ds1])  # Put ds1 in A

        pb = pa.create_project("test_move_dataset_B")
        pa.add_user(fo, edit=True)

        # Move ds4 to B as the other user
        fo_pa = get_project(pa.name, fo_site)
        fo_pa.place(ds4, path="| %s" % pb.name)
        pb.resource.refresh()
        self.assertItemsEqual(
            pb.resource.index.keys(),
            # Only ds4 here
            [_ds4.self])

        fo_ds1 = get_dataset(_ds1.body.id, connection=fo_site)
        fo_pa.place(fo_ds1, path="| %s" % pb.name)

        pb.resource.refresh()
        self.assertItemsEqual(pb.resource.index.keys(), [_ds1.self, _ds4.self])
        pa.place(ds2, path="| %s" % pb.name)

        pb.resource.refresh()
        self.assertItemsEqual(pb.resource.index.keys(),
                              [_ds1.self, _ds2.self, _ds4.self])
        self.assertEqual(ds2.resource.project.self, pb.url)
コード例 #4
0
ファイル: test_utilities.py プロジェクト: AlasdairE/scrunch
    def test_get_project(self, session):

        shoji_entity = {
            "element": "shoji:catalog",
            "body": {
                "name": "Y Team",
                "id": "614a7b2ebe9a4292bba54edce83563ae"
            }
        }

        site_mock = mock.MagicMock(**shoji_entity)
        site_mock.entity = mock.MagicMock(**shoji_entity)
        session.projects.by.side_effect = _by_side_effect(shoji_entity, site_mock)

        project = get_project('Y Team')
        session.projects.by.assert_called_with('name')
        assert isinstance(project, Project)
        assert project.id == '614a7b2ebe9a4292bba54edce83563ae'
コード例 #5
0
ファイル: test_projects.py プロジェクト: anderstheet/scrunch
 def test_rename(self):
     project = new_project("test_rename")
     new_name = "renamed" + UNIQUE_PREFIX
     project.rename(new_name)
     _project = get_project(new_name)
     self.assertEqual(_project.url, project.url)