Exemple #1
0
 def test_get_today_dates_found_one(self):
     today = date.today()
     with MongoConnector(Date, is_test=True) as db:
         new_id = db.create(
             Date.from_request({
                 "name": "An Anniversary",
                 "day": today.strftime("%d"),
                 "month": today.strftime("%m"),
                 "year": "1924",
                 "notes": ["don't forget", "buy them a gift"],
                 "tags": [],
             }))
         self.ids_to_cleanup.append(new_id)
     response = self.verify_response_code(
         self.app.get("/api/v1/dates/today"), 200)
     dates = self.assertFieldIn(response, field="dates")
     self.assertEqual(len(dates), 1,
                      f"Expected only 1 Date returned -- {response}")
     self.assertEqual(
         dates[0]["name"],
         "An Anniversary",
         f"Expected 'An Anniversary' for the name -- {response}",
     )
Exemple #2
0
 def test_delete_housing(self):
     with MongoConnector(Housing, is_test=True) as db:
         new_id = db.create(
             Housing.from_request({
                 "address": {
                     "number": "123",
                     "street": "Main St",
                     "extra": "APT 456",
                     "city": "Nowhere",
                     "state": "NE",
                     "zip_code": "98765",
                 },
                 "start_month": "1",
                 "start_year": "2020",
                 "end_month": "5",
                 "end_year": "2020",
                 "monthly_payment": 1545,
                 "tags": [],
             }))
         self.ids_to_cleanup.append(new_id)
     response = self.verify_response_code(
         self.app.delete(f"/api/v1/housings/{new_id}"), 204)
     self.assertEqual(response, {},
                      f"Expected empty response -- {response}")
Exemple #3
0
 def setUp(self) -> None:
     self.item_type = Date
     super().setUp()
     self.test_dates = [
         {
             "name": "An Anniversary",
             "day": "25",
             "month": "4",
             "year": "1924",
             "notes": ["don't forget", "buy them a gift"],
             "tags": [],
         },
         {
             "name": "A Birthday",
             "day": "16",
             "month": "2",
             "year": "",
             "notes": [],
             "tags": [],
         },
     ]
     with MongoConnector(Date, is_test=True) as db:
         for date in self.test_dates:
             self.ids_to_cleanup.append(db.create(Date.from_request(date)))
Exemple #4
0
 def test_delete_recipe(self):
     with MongoConnector(Recipe, is_test=True) as db:
         new_id = db.create(
             Recipe.from_request(
                 {
                     "name": "Marshmallows",
                     "ingredients": [
                         {
                             "amount": "all",
                             "item": "marshmallow"
                         },
                     ],
                     "instructions": ["mix"],
                     "recipe_type": RecipeType.Dessert,
                     "url": "",
                     "source": "",
                     "notes": [],
                     "tags": [],
                 }, ))
         self.ids_to_cleanup.append(new_id)
     response = self.verify_response_code(
         self.app.delete(f"/api/v1/recipes/{new_id}"), 204)
     self.assertEqual(response, {},
                      f"Expected empty response -- {response}")
Exemple #5
0
 def test_delete_tag(self):
     with MongoConnector(Tag, is_test=True) as db:
         new_id = db.create(Tag.from_request({"name": "TEST_DELETE_TAG"}))
         self.ids_to_cleanup.append(new_id)
     response = self.verify_response_code(self.app.delete(f"/api/v1/tags/{new_id}"), 204)
     self.assertEqual(response, {}, f"Expected empty response -- {response}")