예제 #1
0
    def test_source_file_not_a_valid_archive(self):
        fd, source_input = tempfile.mkstemp()
        os.close(fd)
        # In python2.6, an empty file can be opened as a tar archive.
        # We fill it up so that it fails.
        with open(source_input, 'w') as f:
            f.write('something')

        try:
            with pytest.raises(wagon.WagonError) as ex:
                wagon.get_source(source_input)
            assert 'Failed to extract' in str(ex)
        finally:
            os.remove(source_input)
예제 #2
0
 def test_create_archive_from_path_and_validate(self):
     source = wagon.get_source(TEST_TAR)
     fd, requirements_file_path = tempfile.mkstemp()
     os.close(fd)
     with open(requirements_file_path, 'w') as requirements_file:
         requirements_file.write('wheel')
     result = _wagon([
         'create', source, '-v', '-f', '--validate',
         '--wheel-args=-r {0}'.format(requirements_file_path)
     ])
     try:
         python_version = sys.version_info
         if python_version[0] == 3:
             expected_number_of_wheels = 6
         elif python_version[0] == 2 and python_version[1] == 7:
             expected_number_of_wheels = 6
         elif python_version[0] == 2 and python_version[1] == 6:
             expected_number_of_wheels = 6
         metadata = self._test(
             result=result,
             expected_number_of_wheels=expected_number_of_wheels)
     finally:
         os.remove(requirements_file_path)
     assert metadata['package_source'] == source
     assert any(whl for whl in metadata['wheels']
                if whl.startswith('wheel'))
예제 #3
0
 def test_source_pypi_with_version(self):
     source_input = TEST_PACKAGE
     source_output = wagon.get_source(source_input)
     test_package = '{0}=={1}'.format(
         wagon._get_package_info_from_pypi(TEST_PACKAGE_NAME)['name'],
         TEST_PACKAGE_VERSION)
     assert source_output == test_package
예제 #4
0
 def setup_method(self, test_method):
     self.archive_path = wagon.create(source=TEST_PACKAGE, force=True)
     # wagon._unzip(self.archive_path, '.')
     self.extracted_source = wagon.get_source(self.archive_path)
     self.expected_metadata = wagon._get_metadata(self.extracted_source)
예제 #5
0
 def test_source_pypi_no_version(self):
     source_input = TEST_PACKAGE_NAME
     source_output = wagon.get_source(source_input)
     assert source_output == \
         wagon._get_package_info_from_pypi(TEST_PACKAGE_NAME)['name']