Esempio n. 1
0
    def test_draft_apps_no_projects(self):
        """Test CACHE USERS draft_apps returns an empty list if the user has no
        draft projects"""
        user = UserFactory.create()
        published_project = AppFactory.create(owner=user)

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 0, draft_projects
Esempio n. 2
0
    def test_draft_apps_hidden(self):
        """Test CACHE USERS draft_apps returns a project that belongs to the
        user and is a draft, even it's marked as hidden"""
        user = UserFactory.create()
        hidden_draft_project = AppFactory.create(owner=user, hidden=1, info={})

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 1, draft_projects
Esempio n. 3
0
    def test_draft_apps_return_drafts(self):
        """Test CACHE USERS draft_apps returns draft belonging to the user"""
        user = UserFactory.create()
        draft_project = AppFactory.create(owner=user, info={})

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 1, draft_projects
        assert draft_projects[0]['short_name'] == draft_project.short_name, draft_projects
Esempio n. 4
0
    def test_draft_apps_hidden(self):
        """Test CACHE USERS draft_apps returns a project that belongs to the
        user and is a draft, even it's marked as hidden"""
        user = UserFactory.create()
        hidden_draft_project = AppFactory.create(owner=user, hidden=1, info={})

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 1, draft_projects
Esempio n. 5
0
    def test_draft_apps_no_projects(self):
        """Test CACHE USERS draft_apps returns an empty list if the user has no
        draft projects"""
        user = UserFactory.create()
        published_project = AppFactory.create(owner=user)

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 0, draft_projects
Esempio n. 6
0
    def test_draft_apps_return_drafts(self):
        """Test CACHE USERS draft_apps returns draft belonging to the user"""
        user = UserFactory.create()
        draft_project = AppFactory.create(owner=user, info={})

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 1, draft_projects
        assert draft_projects[0][
            'short_name'] == draft_project.short_name, draft_projects
Esempio n. 7
0
    def test_draft_apps_returns_fields(self):
        """Test CACHE USERS draft_apps returns the info of the projects with
        the required fields"""
        user = UserFactory.create()
        draft_project = AppFactory.create(owner=user, info={})
        fields = ('id', 'name', 'short_name', 'owner_id', 'description', 'info')

        draft_project = cached_users.draft_apps(user.id)

        for field in fields:
            assert field in draft_project[0].keys(), field
Esempio n. 8
0
    def test_draft_apps_only_returns_drafts(self):
        """Test CACHE USERS draft_apps does not return any apps that are not draft
        (published) or drafts that belong to another user"""
        user = UserFactory.create()
        published_project = AppFactory.create(owner=user)
        TaskFactory.create(app=published_project)
        other_users_draft_project = AppFactory.create(info={})

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 0, draft_projects
Esempio n. 9
0
    def test_draft_apps_only_returns_drafts(self):
        """Test CACHE USERS draft_apps does not return any apps that are not draft
        (published) or drafts that belong to another user"""
        user = UserFactory.create()
        published_project = AppFactory.create(owner=user)
        TaskFactory.create(app=published_project)
        other_users_draft_project = AppFactory.create(info={})

        draft_projects = cached_users.draft_apps(user.id)

        assert len(draft_projects) == 0, draft_projects
Esempio n. 10
0
    def test_draft_apps_returns_fields(self):
        """Test CACHE USERS draft_apps returns the info of the projects with
        the required fields"""
        user = UserFactory.create()
        draft_project = AppFactory.create(owner=user, info={})
        fields = ('id', 'name', 'short_name', 'owner_id', 'description',
                  'overall_progress', 'n_tasks', 'n_volunteers', 'info')

        draft_project = cached_users.draft_apps(user.id)

        for field in fields:
            assert field in draft_project[0].keys(), field
Esempio n. 11
0
def _get_user_apps(user_id):
    apps_published = cached_users.published_apps(user_id)
    apps_draft = cached_users.draft_apps(user_id)
    return apps_published, apps_draft
Esempio n. 12
0
def _get_user_apps(user_id):
    apps_published = cached_users.published_apps(user_id)
    apps_draft = cached_users.draft_apps(user_id)
    return apps_published, apps_draft