# Path: pyp2rpm/dependency_parser.py
# def dependency_to_rpm(dep, runtime, use_rich_deps=True):
#     """Converts a dependency got by pkg_resources.Requirement.parse()
#     to RPM format.
#     Args:
#         dep - a dependency retrieved by pkg_resources.Requirement.parse()
#         runtime - whether the returned dependency should be runtime (True)
#         or build time (False)
#     Returns:
#         List of semi-SPECFILE dependencies (package names are not properly
#         converted yet).
#         For example: [['Requires', 'jinja2', '{name}'],
#                       ['Conflicts', 'jinja2', '{name} = 2.0.1']]
#     """
#     logger.debug('Dependencies provided: {0} runtime: {1}.'.format(
#         dep, runtime))
#     converted = convert_requirement(dep, use_rich_deps)
# 
#     if not runtime:
#         for conv in converted:
#             conv[0] = "Build" + conv[0]
#     logger.debug('Converted dependencies: {0}.'.format(converted))
# 
#     return converted


import pytest
from pkg_resources import Requirement as R
from pyp2rpm.dependency_parser import dependency_to_rpm
         [['Requires', 'pyp2rpm', '{name} >= 0.9.3.1'],
          ['Requires', 'pyp2rpm', '{name} < 0.9.4']
         ]
         ),
        ('docutils>=0.3,<1,!=0.5', True, True,
         [['Requires', 'docutils',
           '({name} >= 0.3 with {name} < 1~~ with ({name} < 0.5 or {name} > 0.5))']
          ]
         ),
        ('pytest>=0.3a5,<1.1.1.1,!=1', False, True,
         [['BuildRequires', 'pytest',
           '({name} >= 0.3~a5 with {name} < 1.1.1.1~~ with ({name} < 1 or {name} > 1))']
          ]
         ),
        ('pyp2rpm~=3.3.0rc2', True, True,
         [['Requires', 'pyp2rpm', '({name} >= 3.3~rc2 with {name} < 3.4)']]
         ),
        ('pyp2rpm~=0.9.3', True, True,
         [['Requires', 'pyp2rpm', '({name} >= 0.9.3 with {name} < 0.10)']]
         ),
        ('pyp2rpm~=0.9.3.1', True, True,
         [['Requires', 'pyp2rpm', '({name} >= 0.9.3.1 with {name} < 0.9.4)']]
         ),
        ('nb2plots>0+unknown', True, True,
         [['Requires', 'nb2plots', '{name} > 0.0']]
         ),

    ])
    def test_dependency_to_rpm(self, d, r, rich, expected):
        # we can't convert lists of lists into sets => compare len and contents

# Path: pyp2rpm/dependency_parser.py
# def dependency_to_rpm(dep, runtime, use_rich_deps=True):
#     """Converts a dependency got by pkg_resources.Requirement.parse()
#     to RPM format.
#     Args:
#         dep - a dependency retrieved by pkg_resources.Requirement.parse()
#         runtime - whether the returned dependency should be runtime (True)
#         or build time (False)
#     Returns:
#         List of semi-SPECFILE dependencies (package names are not properly
#         converted yet).
#         For example: [['Requires', 'jinja2', '{name}'],
#                       ['Conflicts', 'jinja2', '{name} = 2.0.1']]
#     """
#     logger.debug('Dependencies provided: {0} runtime: {1}.'.format(
#         dep, runtime))
#     converted = convert_requirement(dep, use_rich_deps)
# 
#     if not runtime:
#         for conv in converted:
#             conv[0] = "Build" + conv[0]
#     logger.debug('Converted dependencies: {0}.'.format(converted))
# 
#     return converted


# Path: tests/test_dependency_parser.py
import pytest
from pkg_resources import Requirement as R
from pyp2rpm.dependency_parser import dependency_to_rpm

         [['Requires', 'pyp2rpm', '{name} >= 0.9.3.1'],
          ['Requires', 'pyp2rpm', '{name} < 0.9.4']
         ]
         ),
        ('docutils>=0.3,<1,!=0.5', True, True,
         [['Requires', 'docutils',
           '({name} >= 0.3 with {name} < 1~~ with ({name} < 0.5 or {name} > 0.5))']
          ]
         ),
        ('pytest>=0.3a5,<1.1.1.1,!=1', False, True,
         [['BuildRequires', 'pytest',
           '({name} >= 0.3~a5 with {name} < 1.1.1.1~~ with ({name} < 1 or {name} > 1))']
          ]
         ),
        ('pyp2rpm~=3.3.0rc2', True, True,
         [['Requires', 'pyp2rpm', '({name} >= 3.3~rc2 with {name} < 3.4)']]
         ),
        ('pyp2rpm~=0.9.3', True, True,
         [['Requires', 'pyp2rpm', '({name} >= 0.9.3 with {name} < 0.10)']]
         ),
        ('pyp2rpm~=0.9.3.1', True, True,
         [['Requires', 'pyp2rpm', '({name} >= 0.9.3.1 with {name} < 0.9.4)']]
         ),
        ('nb2plots>0+unknown', True, True,
         [['Requires', 'nb2plots', '{name} > 0.0']]
         ),

    ])
    def test_dependency_to_rpm(self, d, r, rich, expected):
        # we can't convert lists of lists into sets => compare len and contents

        rpm_deps = dependency_to_rpm(R.parse(d), r, rich)