Esempio n. 1
0
 def test_project_list_method(self):
     ''' Add one private and one public project to the database then query. '''
     db_loader.create_project()
     db_loader.create_project(status='p')
     response = generic_service_method_success_test(self, 'project', 'list')
     self.assertEqual(response['response']['type'], 'Projects',
         'System project list service method failed.')
     self.assertEqual(len(response['response']['content']['projects']), 1,
         'Failed to return the correct number of projects.')
Esempio n. 2
0
    def test_project_put_method(self):

        ''' Add a project (not through api) and then update it. '''

        proposal_key = ndb.Key('Proposal', 'fake')
        category_key = ndb.Key('Category', 'everything')
        creator_key = ndb.Key('User', 'fakie')
        name_1 = 'Save the Everything!'
        pitch_1 = 'Save all the animals!'
        name_2 = 'Save everything!!'
        pitch_2 = 'Yeah, save all those things.'

        project_key = db_loader.create_project(name=name_1, pitch=pitch_1,
                    proposal=proposal_key, category=category_key, creator=creator_key)

        params = {
            'key': project_key.urlsafe(),
            'name': name_2,
            'pitch': pitch_2,
        }

        response = generic_service_method_success_test(self, 'project', 'put', params=params)
        self.assertEqual(response['response']['type'], 'Project',
            'Project put service method failed.')
        self.assertEqual(response['response']['content']['name'], name_2,
            'Project put failed to change the name.')
        self.assertEqual(response['response']['content']['pitch'], pitch_2,
            'Project put failed to change the description.')
Esempio n. 3
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        # Create a project called 'fakeproject'.
        self.project_key = db_loader.create_project()
Esempio n. 4
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        # Create a project and a user.
        self.project_key = db_loader.create_project()
        self.user_key = db_loader.create_user()
Esempio n. 5
0
 def test_project_get_method(self):
     ''' Add one private and one public project to the database then query. '''
     project_key = db_loader.create_project()
     key = project_key.urlsafe()
     response = generic_service_method_success_test(self, 'project', 'get', params={'key':key})
     self.assertEqual(response['response']['type'], 'Project',
         'Project get service method failed.')
     self.assertEqual(response['response']['content']['key'], key,
         'Project get method returned the wrong project.')
Esempio n. 6
0
    def test_custom_url_put_method(self):

        ''' Add a custom url through the api and then try again to get an error. '''

        target = db_loader.create_project()
        params = {
            'slug': 'test',
            'target': encrypt(target.urlsafe()),
        }

        response = generic_service_method_success_test(self, 'url', 'put', params=params)
        self.assertEqual(response['response']['type'], 'CustomUrl',
            'CustomUrl put service method failed to create a new custom_url.')
        self.assertEqual(target.get().customurl.urlsafe(), response['response']['content']['key'],
            'Failed to set custom url on target during put.')

        response = generic_service_method_success_test(self, 'url', 'put', params=params, should_fail=True)
        self.assertEqual(response['response']['content']['state'], 'APPLICATION_ERROR', 'Allowed overwriting of a custom url.')