예제 #1
0
    def get(self, request, fileuuid):
        """
        Requires a file UUID.
        Returns a JSON-encoded list of the file's tags on success.
        """
        try:
            es_client = elasticSearchFunctions.get_client()
            tags = elasticSearchFunctions.get_file_tags(es_client, fileuuid)
        except elasticSearchFunctions.ElasticsearchError as e:
            response = {"success": False, "message": str(e)}
            if isinstance(e, elasticSearchFunctions.EmptySearchResultError):
                status_code = 404
            else:
                status_code = 400
            return helpers.json_response(response, status_code=status_code)

        return helpers.json_response(tags)
예제 #2
0
 def test_list_tags_fails_when_file_cant_be_found(self):
     with pytest.raises(elasticSearchFunctions.EmptySearchResultError):
         elasticSearchFunctions.get_file_tags(self.client, 'no_such_file')
예제 #3
0
 def test_set_get_tags(self):
     elasticSearchFunctions.set_file_tags(self.client, self.file_uuid,
                                          ['test'])
     assert elasticSearchFunctions.get_file_tags(
         self.client, self.file_uuid) == ['test']
예제 #4
0
 def test_set_tags(self):
     elasticSearchFunctions.set_file_tags(
         self.client, '2101fa74-bc27-405b-8e29-614ebd9d5a89', ['test'])
     assert elasticSearchFunctions.get_file_tags(
         self.client, '2101fa74-bc27-405b-8e29-614ebd9d5a89') == ['test']
예제 #5
0
 def test_list_tags(self):
     assert elasticSearchFunctions.get_file_tags(
         self.client, 'a410501b-64ac-4b81-92ca-efa9e815366d') == ['test1']