small fixes

This commit is contained in:
Sam
2021-02-04 11:10:47 +00:00
parent 1c55f7da98
commit 12c0ddcbe8
3 changed files with 25 additions and 3 deletions

View File

@@ -127,9 +127,9 @@ def load_coop_managers(request):
logging.info(f"Created Coop: {coop_data}")
coop_counter += 1
coop_user = User.objects.create_user(email=row['email'], company=coop, role='COOP_MANAGER')
logging.info(f"Created User: {coop_user}")
coop_user = User.objects.create_user(email=row['email'], company=coop, role='COOP_MANAGER', is_active=False)
# TODO: send confirmation email
logging.info(f"Created User: {coop_user}")
user_counter += 1
except Exception as e:
logging.error(f"Could not parse {row}")

View File

@@ -81,7 +81,7 @@ class ProductViewSetTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
# authenticated user
def test_auth_user_can_list_instance(self):
def test_auth_user_can_list_instances(self):
"""Regular logged-in user can list instance
"""
# Create instances
@@ -100,6 +100,25 @@ class ProductViewSetTest(APITestCase):
# Assert all instances are returned
self.assertEqual(len(instances), len(response.data))
def test_auth_user_can_get_instance(self):
"""Regular logged-in user can list instance
"""
# Create instances
instance = self.factory()
# Authenticate user
token = get_tokens_for_user(self.user)
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token['access']}")
# Request list
url = f"{self.endpoint}{instance.id}/"
response = self.client.get(url)
# Assert access is allowed
self.assertEqual(response.status_code, status.HTTP_200_OK)
data = json.loads(response.content)
self.assertEquals(instance.id, data['id'])
def test_auth_user_can_create_instance(self):
"""Regular logged-in user can create new instance
"""

View File

@@ -91,6 +91,9 @@ def load_coop_products(request):
new_image = None
else:
new_image = None
# TODO: if tags is empty, auto-generate tags
# assemble instance data
product_data = {
'id': None if row['id'].strip()=='' else row['id'].strip(),