# Path: rvo/validate.py
# def validate(document):
# 
#     fields = [
#         "title",
#         "encrypted",
#         "content",
#         "created",
#         "updated",
#         "tags",
#         "categories"
#     ]
# 
#     # Check if we have an document
#     if not isinstance(document, dict):
#         return False
# 
#     # Verifiy if all fields are existent
#     try:
#         for field in fields:
#             document[field]
#     except KeyError:
#         return False
# 
#     # Check if content is utf8
#     if not isinstance(document["content"], str):
#         if not isinstance(document["content"], unicode):
#             return False
# 
#     # # Check title utf8
#     if not isinstance(document["title"], str):
#         if not isinstance(document["title"], unicode):
#             return False
# 
#     # Check if tags is a list
#     if not isinstance(document["tags"], list):
#         return False
# 
#     # Check if categories is a list
#     if not isinstance(document["categories"], list):
#         return False
# 
#     # Check if create is a valid datetime object
#     if not isinstance(document["created"], datetime.datetime):
#         return False
# 
#     # Check if updated is a valid datetime object
#     if not isinstance(document["updated"], datetime.datetime):
#         return False
# 
#     if not isinstance(document["encrypted"], bool):
#         return False
# 
#     return True


from rvo.validate import validate as validate
import datetime
def test_validate_pass(validation_item):
    assert validate(validation_item)

def test_validate_wrong_field(validation_item):
    del validation_item["content"]
    validation_item["contentXXX"] = "FOO"
    assert not validate(validation_item)

def test_validate_missing_field(validation_item):
    del validation_item["created"]
    assert not validate(validation_item)

def test_validate_missing_field_title(validation_item):
    del validation_item["title"]
    assert not validate(validation_item)

def test_validate_tags_is_not_list_int(validation_item):
    validation_item["tags"] = 12
    assert not validate(validation_item)

def test_validate_tags_is_not_list_str(validation_item):
    validation_item["tags"] = "string"
    assert not validate(validation_item)

def test_validate_categories_is_not_list_int(validation_item):
    validation_item["categories"] = 12
    assert not validate(validation_item)

def test_validate_categories_is_not_list_str(validation_item):
    validation_item["categories"] = "string"

# Path: rvo/validate.py
# def validate(document):
# 
#     fields = [
#         "title",
#         "encrypted",
#         "content",
#         "created",
#         "updated",
#         "tags",
#         "categories"
#     ]
# 
#     # Check if we have an document
#     if not isinstance(document, dict):
#         return False
# 
#     # Verifiy if all fields are existent
#     try:
#         for field in fields:
#             document[field]
#     except KeyError:
#         return False
# 
#     # Check if content is utf8
#     if not isinstance(document["content"], str):
#         if not isinstance(document["content"], unicode):
#             return False
# 
#     # # Check title utf8
#     if not isinstance(document["title"], str):
#         if not isinstance(document["title"], unicode):
#             return False
# 
#     # Check if tags is a list
#     if not isinstance(document["tags"], list):
#         return False
# 
#     # Check if categories is a list
#     if not isinstance(document["categories"], list):
#         return False
# 
#     # Check if create is a valid datetime object
#     if not isinstance(document["created"], datetime.datetime):
#         return False
# 
#     # Check if updated is a valid datetime object
#     if not isinstance(document["updated"], datetime.datetime):
#         return False
# 
#     if not isinstance(document["encrypted"], bool):
#         return False
# 
#     return True


# Path: tests/test_validate.py
from rvo.validate import validate as validate
import datetime

def test_validate_pass(validation_item):
    assert validate(validation_item)

def test_validate_wrong_field(validation_item):
    del validation_item["content"]
    validation_item["contentXXX"] = "FOO"
    assert not validate(validation_item)

def test_validate_missing_field(validation_item):
    del validation_item["created"]
    assert not validate(validation_item)

def test_validate_missing_field_title(validation_item):
    del validation_item["title"]
    assert not validate(validation_item)

def test_validate_tags_is_not_list_int(validation_item):
    validation_item["tags"] = 12
    assert not validate(validation_item)

def test_validate_tags_is_not_list_str(validation_item):
    validation_item["tags"] = "string"
    assert not validate(validation_item)

def test_validate_categories_is_not_list_int(validation_item):
    validation_item["categories"] = 12
    assert not validate(validation_item)

def test_validate_categories_is_not_list_str(validation_item):
    validation_item["categories"] = "string"

    assert not validate(validation_item)