Beispiel #1
0
def save_n_data_requests_with_category(user, n, category):    	
    for i in range(n):
    	data_request = DataRequest(creator=user)
    	data_request.name = 'test_data_request_name_' + str(i)
    	data_request.is_active = True
    	data_request.category = category
    	data_request.save()	
Beispiel #2
0
def save_n_data_requests_with_tag(user, n, tag):    	
    for i in range(n):
    	data_request = DataRequest(creator=user)
    	data_request.name = 'test_data_request_name_' + str(i)
    	data_request.is_active = True
    	data_request.save()
    	Tagging.objects.add_tags_and_return_added_tag_names(tag, data_request, user)	
Beispiel #3
0
	def testDataRequestsPage(self):
		data_request = DataRequest(creator=self.data_request.creator, name="Amazing request", description="Spectacular request indeed")
		data_request.save()
		datarequest_location = '/datarequests/%s/' % (data_request.id)
		response = self.client.get(datarequest_location)
		self.failUnlessEqual(response.status_code, 200, "Error viewing Data Requests!")
		self.failUnless("Spectacular request indeed" in response.content)
Beispiel #4
0
    def testForDataRequests(self):
        """ Test if a User's Data Request is shown in that User's profile. In this case Bill has 4 data requests. """
        login = self.client.login(username="******", password="******")
        self.assertTrue(login)

        user = User.objects.get(username="******")
        datarequest = DataRequest(
            creator=user,
            name="Inbuilt Data request Object with Status U",
            description="Inbuilt Data request Object with Status U for Bill",
            status="U",
        )
        datarequest.save()

        datarequest = DataRequest(
            creator=user,
            name="Inbuilt Data request Object with Status F",
            description="Inbuilt Data request Object with Status F for Bill",
            status="F",
        )
        datarequest.save()

        response = self.client.get("/user/")

        self.failUnless(response.status_code, 200)
        self.failUnless("Your Data Requests" in response.content, response.content)
        self.failUnless("edit" in response.content, response.content)
    def testForNoCanceledDataRequests(self):
        """Test if canceled data requests are published for the logged in
        user.  In this case, Bill has 1 canceled data request which should not
        be published.
        """
        
        self.tryLogin(BILL_USERNAME)

        user = User.objects.get(username=BILL_USERNAME)
        
        datarequest = DataRequest(
            creator=user, 
            name='DataRequest object with Status C (Should not be shown)', 
            description='DataRequest object with Status C for Bill',
            status='C',
            slug='whatever',
            is_active=True)
        datarequest.save()
        
        response = self.client.get(self.profile_url)
        
        self.failUnless(response.status_code, 200)
        self.assertContains(response, 'Your Data Requests')
        self.assertNotContains(response, 'DataRequest object with Status C')
        self.assertContains(response, 'edit')
    def testForDataRequests(self):
        """Test if a User's Data Request is shown in that User's profile. In
        this case Bill has 4 data requests.
        """
        
        self.tryLogin(BILL_USERNAME)
        
        user = User.objects.get(username=BILL_USERNAME)
        
        datarequest1 = DataRequest(
            creator=user, 
            name='DataRequest object with Status U', 
            description='DataRequest object with Status U for Bill',
            status='U',
            slug='whatever',
            is_active=True)
        datarequest1.save()
        
        datarequest2 = DataRequest(
            creator=user, 
            name='DataRequest object with Status F', 
            description='DataRequest object with Status F for Bill',
            status='F',
            slug='whatever',
            is_active=True)
        datarequest2.save()
        
        response = self.client.get(self.profile_url)

        self.failUnless(response.status_code, 200)
        self.assertContains(response, 'Your Data Requests')
        self.assertContains(response, 'edit')
        self.assertContains(response, 'DataRequest object with Status U')
        self.assertContains(response, 'DataRequest object with Status F')
Beispiel #7
0
	def testForDataRequests(self):
		""" Test if a User's Data Request is shown in that User's profile. In this case Bill has 4 data requests. """
		self.tryLogin(username='******', password='******')
		
		user = User.objects.get(username='******')
		datarequest = DataRequest(creator = user, 
									name = 'Inbuilt Data request Object with Status U', 
									description = 'Inbuilt Data request Object with Status U for Bill',
									status = 'U',
									slug = 'whatever'
								)
		datarequest.save()
		
		datarequest = DataRequest(creator = user, 
									name = 'Inbuilt Data request Object with Status F', 
									description = 'Inbuilt Data request Object with Status F for Bill',
									status = 'F',
									slug = 'whatever'
								)
		datarequest.save()
		
		response = self.client.get(self.profile_url)

		self.failUnless(response.status_code, 200)
		self.failUnless("Your Data Requests" in response.content, response.content)
		self.failUnless("edit" in response.content, response.content)
Beispiel #8
0
	def testDataRequestIndexOwned(self):
		creator = User.objects.get(username="******")
		data_request = DataRequest(creator=creator, name="Amazing request", description="Spectacular request indeed", status='U')
		data_request.save()
		login = self.client.login(username='******', password='******')
		self.failUnless(login, 'Could not login')
		response = self.client.get('/datarequests/')
		self.failUnlessEqual(response.status_code, 200)
Beispiel #9
0
	def testLifeCycle(self):
		data_request = DataRequest(creator=self.data_request.creator, name="Amazing request", description="Spectacular request indeed")
		data_request.save()
		self.assertEqual(2, DataRequest.objects.unfulfilled().count())
		data_request.fulfill()
		data_request.save()
		self.assertEqual(1, DataRequest.objects.unfulfilled().count())
		self.assertEqual(1, DataRequest.objects.fulfilled().count())
		self.assertEqual(data_request.name, DataRequest.objects.fulfilled()[0].name)
Beispiel #10
0
	def testStatusExistsAtIndex(self):
		data_request = DataRequest(creator=self.data_request.creator, name="Amazing request", description="Spectacular request indeed", status='F')
		data_request.save()
		datarequest_location = '/datarequests/%s/' % (data_request.id)
		response = self.client.get(datarequest_location)
		self.failUnlessEqual(response.status_code, 200, "Error viewing Data Requests!")
		self.failUnless("Spectacular request indeed" in response.content)
		self.failUnless("Fulfilled" in response.content)
		response = self.client.get('/datarequests/')
		self.failUnlessEqual(response.status_code, 200, "Error listing Data Requests!")
		self.failIf("Fulfilled" in response.content)
Beispiel #11
0
	def testDataRequestCancelOwned(self):
		creator = User.objects.get(username="******")
		data_request = DataRequest(creator=creator, name="Amazing request", description="Spectacular request indeed", status='U')
		data_request.save()
		login = self.client.login(username='******', password='******')
		self.failUnless(login, 'Could not login')
		datarequesturl = '/datarequests/%s/cancel/' % (data_request.id)
		response = self.client.get(datarequesturl)
		self.failUnlessEqual(response.status_code, 302)
		response = self.client.get('/datarequests/')
		self.failUnlessEqual(response.status_code, 200)
		self.failIf("Amazing request" in response.content)
Beispiel #12
0
	def testDataRequestIndexOwnedFulfilled(self):
		creator = User.objects.get(username="******")
		data_request = DataRequest(creator=creator, name="Amazing request", description="Spectacular request indeed", status='F')
		data_request.save()
		login = self.client.login(username='******', password='******')
		self.failUnless(login, 'Could not login')
		response = self.client.get('/datarequests/')
		self.failUnlessEqual(response.status_code, 200)
		self.failUnless('Amazing request' in response.content, "Just-created request not on request page")
		self.failIf('Edit</a>' in response.content, "request owner has a link to edit the request on request page")
		self.failIf('Canceled</a>' in response.content, "request owner has a link to cancel the request on request page")
		self.failIf('Fulfill</a>' in response.content, "request owner has a link to fulfill the request on request page")
Beispiel #13
0
	def testDataRequestPageOwnedC(self):
		creator = User.objects.get(username="******")
		data_request = DataRequest(creator=creator, name="Amazing request", description="Spectacular request indeed", status='C')
		data_request.save()
		login = self.client.login(username='******', password='******')
		self.failUnless(login, 'Could not login')
		datarequesturl = '/datarequests/%s/' % (data_request.id)
		response = self.client.get(datarequesturl)
		self.failUnlessEqual(response.status_code, 200)
		self.failUnless('Amazing request' in response.content, response.content)
		self.failIf('Edit</a>' in response.content, response.content)
		self.failIf('Canceled</a>' in response.content)
		self.failIf('Fulfilled</a>' in response.content)
Beispiel #14
0
	def testForNoCanceledDataRequests(self):
		""" Test if canceled data requests are published for the logged in user. In this case,
 		Bill has 1 canceled data request which should not be published. """
		self.tryLogin(username='******', password='******')

		user = User.objects.get(username='******')
		datarequest = DataRequest(creator = user, 
									name = 'Inbuilt Data request Object with Status C <- should not be shown', 
									description = 'Inbuilt Data request Object with Status C for Bill',
									status = 'C',
									slug = 'whatever'
								)
		datarequest.save()
		
		response = self.client.get(self.profile_url)
		
		self.failUnless(response.status_code, 200)
		self.failUnless("Your Data Requests" in response.content, response.content)
		self.failIf("Status C" in response.content, response.content)
		self.failUnless("edit" in response.content, response.content)
Beispiel #15
0
    def testForNoCancelledDataRequests(self):
        """ Test if canceled data requests are published for the logged in user. In this case,
 		Bill has 1 canceled data request which should not be published. """
        login = self.client.login(username="******", password="******")
        self.assertTrue(login)

        user = User.objects.get(username="******")
        datarequest = DataRequest(
            creator=user,
            name="Inbuilt Data request Object with Status C <- should not be shown",
            description="Inbuilt Data request Object with Status C for Bill",
            status="C",
        )
        datarequest.save()

        response = self.client.get("/user/")

        self.failUnless(response.status_code, 200)
        self.failUnless("Your Data Requests" in response.content, response.content)
        self.failIf("Status C" in response.content, response.content)
        self.failUnless("edit" in response.content, response.content)
Beispiel #16
0
	def testIndex(self):
		data_request = DataRequest(creator=self.data_request.creator, name="Amazing request", description="Spectacular request indeed")
		data_request.save()
		response = self.client.get('/datarequests/')
		self.failUnlessEqual(response.status_code, 200, "Error listing Data Requests!")
		self.failUnless("Amazing request" in response.content)
Beispiel #17
0
	def testCanceledNotViewableAtIndex(self):
		data_request = DataRequest(creator=self.data_request.creator, name="Amazing request", description="Spectacular request indeed", status='C')
		data_request.save()
		response = self.client.get('/datarequests/')
		self.failIf("Canceled" in response.content)
Beispiel #18
0
def save_n_data_requests(user, n):    	
    for i in range(n):
    	data_request = DataRequest(creator=user)
    	data_request.name = 'test_data_request_name_' + str(i)
    	data_request.is_active = True
    	data_request.save()