def setUp(self) -> None:
     """Setup for test case"""
     self.user = test_utils.create_dummyuser()
     self.fridge = test_utils.create_dummyfridge("Fridge A")
     self.fridge_b = test_utils.create_dummyfridge("Fridge B")
     test_utils.connect_fridge_user(self.user.username, self.fridge.name)
     test_utils.connect_fridge_user(self.user.username, self.fridge_b.name)
     self.item_a = test_utils.create_items("Item A")
     self.item_b = test_utils.create_items("Item B")
     date = timezone.datetime.now() + timezone.timedelta(days=1)
     date_future = timezone.datetime.now() + timezone.timedelta(days=10)
     test_utils.create_fridge_content(self.item_a.item_id,
                                      self.fridge.fridge_id,
                                      year=date_future.year,
                                      month=date_future.month,
                                      day=date_future.day)
     test_utils.create_fridge_content(self.item_b.item_id,
                                      self.fridge.fridge_id,
                                      year=date.year,
                                      month=date.month,
                                      day=date.day)
     test_utils.create_fridge_content(self.item_a.item_id,
                                      self.fridge_b.fridge_id,
                                      year=date.year,
                                      month=date.month,
                                      day=date.day)
Exemplo n.º 2
0
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     test_utils.create_items("Item A")
     test_utils.create_items("Item B")
     test_utils.create_api_token(timezone.now() +
                                 timezone.timedelta(hours=1))
Exemplo n.º 3
0
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     test_utils.create_dummyfridge()
     test_utils.connect_fridge_user()
     test_utils.create_login_token(timezone.now() +
                                   timezone.timedelta(days=14))
     test_utils.create_api_token(timezone.now() +
                                 timezone.timedelta(days=14))
     test_utils.create_items("Item A")
     test_utils.create_items("Item B")
     test_utils.create_fridge_content(
         test_utils.get_item("Item A").values()[0]["item_id"],
         test_utils.get_fridge("Dummy Fridge").values()[0]["fridge_id"])
Exemplo n.º 4
0
    def test_barcode_view_exp_item_exists_200(self):
        """Get item w/ barcode. Expecting 200 response"""
        barcode_string = ItemsSerializer(
            test_utils.create_items("Item C")).data["barcode"]
        request = self.factory.get(f"/items/barcode/{barcode_string}/")
        request.META["HTTP_AUTHORIZATION"] = "APIToken"

        response = barcode.barcode_view(request, barcode_string)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 5
0
    def test_id_view_item_exists_exp_200(self):
        """Get item w/ id successfully. Expecting 200 response"""
        item_id = ItemsSerializer(
            test_utils.create_items("Item C")).data["item_id"]
        request = self.factory.get(f"/items/id/{item_id}/")
        request.META["HTTP_AUTHORIZATION"] = "APIToken"

        response = items_id.id_view(request, item_id)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
 def setUp(self):
     """Setup for test case"""
     self.factory = RequestFactory()
     test_utils.setup()
     test_utils.create_dummyuser()
     test_utils.create_dummyuser("us2", "user", "name", "[email protected]")
     test_utils.create_dummyfridge()
     test_utils.connect_fridge_user()
     test_utils.create_items("Item A")
     test_utils.create_items("Item B")
     test_utils.create_login_token(
         timezone.now() + timezone.timedelta(hours=1)
     )
     test_utils.create_api_token(
         timezone.now() + timezone.timedelta(hours=1)
     )
     test_utils.create_api_token(
         timezone.now() + timezone.timedelta(hours=1),
         username="******",
         tok="APIToken2"
     )