예제 #1
0
 def create_from_requirements(self, requirements):
     """ Create job from requirements.txt contents
     """
     reqs_list = parse_requirements(requirements)
     job = Job.objects.create(requirements=requirements)
     for package_name, version in reqs_list:
         if not version:  # Ignore packages without versions (for now)
             continue
         package, _ = Package.objects.get_or_create(slug=normalize_package_name(package_name),
                                                    defaults={'name': package_name})
         spec, _ = Spec.objects.get_or_create(package=package, version=version)
         JobSpec.objects.create(job=job, spec=spec)
     return job
예제 #2
0
    def test_spec_parser(self):
        incoming_requirements = "django==1.4.3\ndjango-storages"

        self.assertEqual(parse_requirements(incoming_requirements),
                         [('django', '1.4.3'),
                          ('django-storages', None)])