def test_update_stack_name_no_access(self): stack = SupplementStackFactory(user=self.user_1) cool_name = "cool name" params = {"name": cool_name} url = stack.get_update_url() # use a different client to make sure no data response = self.client_2.post(url, data=params) self.assertEqual(404, response.status_code)
def test_update_stack_name(self): stack = SupplementStackFactory(user=self.user_1) cool_name = "cool name" params = {"name": cool_name} url = stack.get_update_url() response = self.client_1.post(url, data=params) data = response.data self.assertEqual(data["name"], cool_name)
def test_get_view_with_supplement_compositions(self): stack = SupplementStackFactory(user=self.user_1) compositions_to_create = 3 created_comps = SupplementStackCompositionFactory.create_batch( compositions_to_create, stack=stack, user=self.user_1 ) # sometimes the randomness makes it not quite equal to how many we wanted to create created_comps_length = len(set(created_comps)) url = stack.get_update_url() response = self.client_1.get(url) self.assertIsNotNone(response.data["compositions"]) self.assertEqual(created_comps_length, len(response.data["compositions"]))