fixes to purchase_email and readme update
This commit is contained in:
@@ -1210,12 +1210,13 @@ class PurchaseEmailTest(APITestCase):
|
||||
self.password = ''.join(random.choices(string.ascii_uppercase, k = 10))
|
||||
self.user = CustomUserFactory(email=self.email, is_active=True)
|
||||
self.user.set_password(self.password)
|
||||
# self.user.role = 'SITE_ADMIN'
|
||||
self.user.save()
|
||||
|
||||
def test_anon_user_can_use(self):
|
||||
|
||||
company = CompanyFactory()
|
||||
self.user.role = 'COOP_MANAGER'
|
||||
self.user.company = company
|
||||
self.user.save()
|
||||
product = ProductFactory(company=company)
|
||||
|
||||
data = {
|
||||
@@ -1225,8 +1226,29 @@ class PurchaseEmailTest(APITestCase):
|
||||
'product': product.id,
|
||||
'comment': '',
|
||||
}
|
||||
response = self.client.post(self.endpoint, json=data)
|
||||
import ipdb; ipdb.set_trace()
|
||||
response = self.client.post(self.endpoint, data=data, format='json')
|
||||
# assertions
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEquals(2, len(mail.outbox))
|
||||
|
||||
def test_auth_user_can_use(self):
|
||||
company = CompanyFactory()
|
||||
self.user.role = 'COOP_MANAGER'
|
||||
self.user.company = company
|
||||
self.user.save()
|
||||
product = ProductFactory(company=company)
|
||||
|
||||
data = {
|
||||
'telephone': '123123123',
|
||||
'company': company.id,
|
||||
'product': product.id,
|
||||
'comment': '',
|
||||
}
|
||||
# Authenticate
|
||||
token = get_tokens_for_user(self.user)
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token['access']}")
|
||||
|
||||
response = self.client.post(self.endpoint, data=data, format='json')
|
||||
# assertions
|
||||
self.assertEquals(response.status_code, 200)
|
||||
self.assertEquals(2, len(mail.outbox))
|
||||
|
||||
Reference in New Issue
Block a user