# Path: pyston/utils/compatibility.py
# def is_relation(model, field_name):
#     return (
#         is_one_to_one(model, field_name) or
#         is_many_to_one(model, field_name) or
#         is_many_to_many(model, field_name) or
#         is_reverse_one_to_one(model, field_name) or
#         is_reverse_many_to_one(model, field_name) or
#         is_reverse_many_to_many(model, field_name)
#     )
# 
# def is_one_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and not field.auto_created and field.one_to_one
# 
# def is_many_to_many(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and not field.auto_created and field.many_to_many
# 
# def is_many_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and not field.auto_created and field.many_to_one
# 
# def is_reverse_many_to_many(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and field.auto_created and field.many_to_many
# 
# def is_reverse_many_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and field.auto_created and field.one_to_many
# 
# def is_reverse_one_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and field.auto_created and field.one_to_one
# 
# def get_model_from_relation(model, field_name):
#     try:
#         related_model = model._meta.get_field(field_name).related_model
#         if related_model:
#             return related_model
#         else:
#             raise FieldError('field {} is not relation'.format(field_name))
#     except FieldDoesNotExist:
#         raise FieldError('field {} is not relation'.format(field_name))
# 
# def get_model_from_relation_or_none(model, field_name):
#     try:
#         return get_model_from_relation(model, field_name)
#     except FieldError:
#         return None
# 
# def get_reverse_field_name(model, field_name):
#     """
#     Gets reverse field name, but for reverse fields must be set related_name,
#     therefore must be check if it was set by getting reverse field from the reverse model
#     """
#     try:
#         model_field = model._meta.get_field(field_name)
#         reverse_field_name = model_field.remote_field.name
#         model_field.related_model._meta.get_field(reverse_field_name)
#         return reverse_field_name
#     except (FieldDoesNotExist, AttributeError):
#         raise FieldError('field {} is not relation'.format(field_name))


from unittest.case import TestCase
from django.core.exceptions import FieldError
from germanium.tools import assert_true, assert_false, assert_raises, assert_equal, assert_is_none
from pyston.utils.compatibility import (
    is_relation, is_one_to_one, is_many_to_many, is_many_to_one, is_reverse_many_to_many, is_reverse_many_to_one,
    is_reverse_one_to_one, get_model_from_relation, get_model_from_relation_or_none, get_reverse_field_name
)
from app.models import Issue, User
        assert_false(is_many_to_many(Issue, 'solver'))
        assert_false(is_many_to_many(Issue, 'leader'))
        assert_false(is_many_to_many(Issue, 'name'))
        assert_false(is_many_to_many(Issue, 'created_at'))
        assert_false(is_many_to_many(Issue, 'invalid'))

        assert_false(is_many_to_many(User, 'watched_issues'))
        assert_false(is_many_to_many(User, 'created_issues'))
        assert_false(is_many_to_many(User, 'solving_issue'))
        assert_false(is_many_to_many(User, 'leading_issue'))

    def test_is_reverse_one_to_one(self):
        assert_false(is_reverse_one_to_one(Issue, 'watched_by'))
        assert_false(is_reverse_one_to_one(Issue, 'created_by'))
        assert_false(is_reverse_one_to_one(Issue, 'solver'))
        assert_false(is_reverse_one_to_one(Issue, 'leader'))
        assert_false(is_reverse_one_to_one(Issue, 'name'))
        assert_false(is_reverse_one_to_one(Issue, 'created_at'))
        assert_false(is_reverse_one_to_one(Issue, 'invalid'))

        assert_false(is_reverse_one_to_one(User, 'watched_issues'))
        assert_false(is_reverse_one_to_one(User, 'created_issues'))
        assert_true(is_reverse_one_to_one(User, 'solving_issue'))
        assert_true(is_reverse_one_to_one(User, 'leading_issue'))

    def test_is_reverse_many_to_one(self):
        assert_false(is_reverse_many_to_one(Issue, 'watched_by'))
        assert_false(is_reverse_many_to_one(Issue, 'created_by'))
        assert_false(is_reverse_many_to_one(Issue, 'solver'))
        assert_false(is_reverse_many_to_one(Issue, 'leader'))

# Path: pyston/utils/compatibility.py
# def is_relation(model, field_name):
#     return (
#         is_one_to_one(model, field_name) or
#         is_many_to_one(model, field_name) or
#         is_many_to_many(model, field_name) or
#         is_reverse_one_to_one(model, field_name) or
#         is_reverse_many_to_one(model, field_name) or
#         is_reverse_many_to_many(model, field_name)
#     )
# 
# def is_one_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and not field.auto_created and field.one_to_one
# 
# def is_many_to_many(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and not field.auto_created and field.many_to_many
# 
# def is_many_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and not field.auto_created and field.many_to_one
# 
# def is_reverse_many_to_many(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and field.auto_created and field.many_to_many
# 
# def is_reverse_many_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and field.auto_created and field.one_to_many
# 
# def is_reverse_one_to_one(model, field_name):
#     field = get_field_or_none(model, field_name)
#     return field and field.auto_created and field.one_to_one
# 
# def get_model_from_relation(model, field_name):
#     try:
#         related_model = model._meta.get_field(field_name).related_model
#         if related_model:
#             return related_model
#         else:
#             raise FieldError('field {} is not relation'.format(field_name))
#     except FieldDoesNotExist:
#         raise FieldError('field {} is not relation'.format(field_name))
# 
# def get_model_from_relation_or_none(model, field_name):
#     try:
#         return get_model_from_relation(model, field_name)
#     except FieldError:
#         return None
# 
# def get_reverse_field_name(model, field_name):
#     """
#     Gets reverse field name, but for reverse fields must be set related_name,
#     therefore must be check if it was set by getting reverse field from the reverse model
#     """
#     try:
#         model_field = model._meta.get_field(field_name)
#         reverse_field_name = model_field.remote_field.name
#         model_field.related_model._meta.get_field(reverse_field_name)
#         return reverse_field_name
#     except (FieldDoesNotExist, AttributeError):
#         raise FieldError('field {} is not relation'.format(field_name))


# Path: example/dj/apps/app/tests/compatibility.py
from unittest.case import TestCase
from django.core.exceptions import FieldError
from germanium.tools import assert_true, assert_false, assert_raises, assert_equal, assert_is_none
from pyston.utils.compatibility import (
    is_relation, is_one_to_one, is_many_to_many, is_many_to_one, is_reverse_many_to_many, is_reverse_many_to_one,
    is_reverse_one_to_one, get_model_from_relation, get_model_from_relation_or_none, get_reverse_field_name
)
from app.models import Issue, User

        assert_false(is_many_to_many(Issue, 'solver'))
        assert_false(is_many_to_many(Issue, 'leader'))
        assert_false(is_many_to_many(Issue, 'name'))
        assert_false(is_many_to_many(Issue, 'created_at'))
        assert_false(is_many_to_many(Issue, 'invalid'))

        assert_false(is_many_to_many(User, 'watched_issues'))
        assert_false(is_many_to_many(User, 'created_issues'))
        assert_false(is_many_to_many(User, 'solving_issue'))
        assert_false(is_many_to_many(User, 'leading_issue'))

    def test_is_reverse_one_to_one(self):
        assert_false(is_reverse_one_to_one(Issue, 'watched_by'))
        assert_false(is_reverse_one_to_one(Issue, 'created_by'))
        assert_false(is_reverse_one_to_one(Issue, 'solver'))
        assert_false(is_reverse_one_to_one(Issue, 'leader'))
        assert_false(is_reverse_one_to_one(Issue, 'name'))
        assert_false(is_reverse_one_to_one(Issue, 'created_at'))
        assert_false(is_reverse_one_to_one(Issue, 'invalid'))

        assert_false(is_reverse_one_to_one(User, 'watched_issues'))
        assert_false(is_reverse_one_to_one(User, 'created_issues'))
        assert_true(is_reverse_one_to_one(User, 'solving_issue'))
        assert_true(is_reverse_one_to_one(User, 'leading_issue'))

    def test_is_reverse_many_to_one(self):
        assert_false(is_reverse_many_to_one(Issue, 'watched_by'))
        assert_false(is_reverse_many_to_one(Issue, 'created_by'))
        assert_false(is_reverse_many_to_one(Issue, 'solver'))
        assert_false(is_reverse_many_to_one(Issue, 'leader'))

        assert_false(is_reverse_many_to_one(Issue, 'name'))