Example #1
0
 def test_name_in_use(self):
     name = json.loads(home({}))[2]["name"]
     body = {
         "name": name,
         "cellphone": 1111111111,
         "address": "Some random address",
         "home_phone": 1111111111,
         "email": None,
         "company": None
     }
     self.assertEqual(post(body), "Name already in use")
Example #2
0
 def test_complete_body(self):
     name = json.loads(home({}))[4]["name"]
     body = {
         "name": name,
         "cellphone": 1111111111,
         "address": "Some random address",
         "home_phone": 1111111111,
         "email": "*****@*****.**",
         "company": "Google"
     }
     self.assertEqual(put(name, body), "Contact updated")
Example #3
0
 def test_partial_body(self):
     name = json.loads(home({}))[3]["name"]
     body = {"company": "Momentum Learning"}
     self.assertEqual(put(name, body), "Contact updated")
Example #4
0
 def test_valid_name(self):
     contact = json.loads(home({}))[1]
     self.assertEqual(contact, json.loads(get(contact["name"])))
Example #5
0
 def test_query(self):
     contact_to_search = json.loads(home({}))[0]
     search_term = contact_to_search["name"].split(" ")[0]
     results = json.loads(home({"query": f"name:{search_term}"}))
     self.assertIn(contact_to_search, results)
Example #6
0
 def test_page(self):
     page1 = json.loads(home({"page": 1}))
     page2 = json.loads(home({"page": 2}))
     self.assertNotEqual(page1[0], page2[0])
Example #7
0
 def test_page_size(self):
     results = json.loads(home({"pageSize": 15}))
     self.assertEqual(len(results), 15)
Example #8
0
 def test_valid_name(self):
     name = json.loads(home({}))[5]["name"]
     delete(name)
     self.assertEqual(get(name), "Contact does not exist")
Example #9
0
def home():
    args = request.args
    return data.home(args)