def test_not_suitable_if_private(self):
        # exists
        self.df.reload_pkg_dicts()
        assert self.df.private_records is not None

        # active
        eq_(self.df.private_records['state'], 'active')

        # has resources
        assert len(self.df.private_records['resources']) > 0

        # resources are active
        active_resources = [
            r['state'] == 'active'
            for r in self.df.private_records['resources']
        ]
        eq_(any(active_resources), True)

        # is private
        eq_(self.df.private_records.get('private', False), True)

        # is suitable
        is_suitable = twitter_pkg_suitable(self.df.context,
                                           self.df.private_records['id'])
        eq_(is_suitable, False)
Пример #2
0
    def after_update(self, context, pkg_dict):

        is_suitable = twitter_helpers.twitter_pkg_suitable(
            context, pkg_dict['id'])
        print is_suitable

        if is_suitable:
            session.setdefault('twitter_is_suitable', pkg_dict['id'])
            session.save()
Пример #3
0
 def after_update(self, context, pkg_dict):
     is_suitable = twitter_helpers.twitter_pkg_suitable(context,
                                                        pkg_dict['id'])
     if is_suitable:
         try:
             session.pop('twitter_is_suitable', '')
             session.setdefault('twitter_is_suitable', pkg_dict['id'])
             session.save()
         except TypeError:
             print "session not iterable"
    def test_not_suitable_if_no_resources(self):
        # exists
        self.df.reload_pkg_dicts()
        assert self.df.public_records is not None

        # active
        eq_(self.df.public_records['state'], 'active')

        # has no resources
        self.df.remove_public_resources()
        eq_(len(self.df.public_records.get('resources', [])), 0)

        # is suitable
        is_suitable = twitter_pkg_suitable(self.df.context,
                                           self.df.public_records['id'])
        eq_(is_suitable, False)

        # undo
        self.df.refresh()
    def test_not_suitable_if_not_active(self):
        # exists
        self.df.reload_pkg_dicts()
        assert self.df.public_records is not None

        # not active
        self.df.deactivate_package(self.df.public_records['id'])
        assert self.df.public_records['state'] != 'active'

        # not draft
        assert self.df.public_records['state'] != 'draft'

        # is suitable
        is_suitable = twitter_pkg_suitable(self.df.context,
                                           self.df.public_records['id'])
        eq_(is_suitable, False)

        # undo the deactivation
        self.df.activate_package(self.df.public_records['id'])
    def test_not_suitable_if_no_active_resources(self):
        pkg_dict = self.df.deactivate_public_resources()
        # exists
        assert pkg_dict is not None

        # active
        eq_(pkg_dict['state'], 'active')

        # has resources
        assert len(pkg_dict['resources']) > 0

        # resources are not active
        active_resources = [
            r['state'] == 'active' for r in pkg_dict['resources']
        ]
        eq_(
            any(active_resources), False,
            '{0}/{1} resources still active'.format(sum(active_resources),
                                                    len(active_resources)))

        # is suitable
        is_suitable = twitter_pkg_suitable(self.df.context, None, pkg_dict)
        eq_(is_suitable, False)
 def test_not_suitable_if_does_not_exist(self):
     is_suitable = twitter_pkg_suitable(self.df.context, 'not-a-real-id')
     eq_(is_suitable, False)