def test_project_save_with_orcid(self): with self.client as client: # Authenticate self.login(client) image_name = "robo_test_image.png" image_path = os.path.join(os.path.dirname(__file__), "images", image_name) with open(image_path, "rb") as img: image = img.read() rv = self.register_project( name="My Awesome project", description=libsum, tags="Robots,Evolution,Individual Learning", image=(io.BytesIO(image), image_name), csrf_token=self.csrf_token, ) test_response = ( "Your submission has been received, " "your metadata can be found at:" ) self.assertIn(bytes(test_response, encoding="utf8"), rv.data) # Clean up Project.clear() self.assertTrue(len(Project.get_all()) == 0)
def test_project_getall_clear(self): Project.clear() self.assertTrue(len(Project.get_all()) == 0) num_project = 10 for _ in range(num_project): project = Project( name="nasiodas", description="sdifosdfios", image=os.path.join("Usdufsi", "sdfs.png"), tags="sdfo,sdfo,sdf", ) project.save() self.assertEqual(len(Project.get_all()), num_project)
def test_tag_post_search(self): Project.clear() self.assertTrue(len(Project.get_all()) == 0) first_tag = "eScience:bohrium:tests" second_tag = "eScience:bohrium:benchmark" num_project = 10 for num in range(num_project): if num % 2 == 0: project = Project( name="nasiodas", description="sdifosdfios", image=os.path.join("Usdufsi", "sdfs.png"), tags=first_tag, ) else: project = Project( name="nasiodas", description="sdifosdfios", image=os.path.join("Usdufsi", "sdfs.png"), tags=second_tag, ) project.save() # Test Post Search -> json response evaluated first_query = json.loads( self.tag_post_query(tag=first_tag).get_data(as_text=True) ) for project in first_query["data"]: self.assertTrue(project["tags"] == first_tag) second_query = json.loads( self.tag_post_query(tag=second_tag).get_data(as_text=True) ) for project in second_query["data"]: # TODO -> test URL GET search query self.assertTrue(project["tags"] == second_tag)
def tearDown(self): # Clean up Project.clear() self.assertTrue(len(Project.get_all()) == 0)