[Notes] [Git][BuildStream/buildstream][chandan/pip-source] more tests



Title: GitLab

Chandan Singh pushed to branch chandan/pip-source at BuildStream / buildstream

Commits:

6 changed files:

Changes:

  • buildstream/plugins/sources/pip.py
    ... ... @@ -86,6 +86,9 @@ class PipSource(Source):
    86 86
             self.packages = self.node_get_member(node, list, 'packages', [])
    
    87 87
             self.requirements_files = self.node_get_member(node, list, 'requirements-files', [])
    
    88 88
     
    
    89
    +        if not (self.packages or self.requirements_files):
    
    90
    +            raise SourceError("{}: Either 'packages' and 'requirements-files' must be specified". format(self))
    
    91
    +
    
    89 92
         def preflight(self):
    
    90 93
             # Try to find a way to open virtual environments on the host
    
    91 94
             try:
    

  • tests/sources/pip.py
    ... ... @@ -33,3 +33,15 @@ def test_first_source(cli, tmpdir, datafiles):
    33 33
             'show', 'target.bst'
    
    34 34
         ])
    
    35 35
         result.assert_main_error(ErrorDomain.ELEMENT, None)
    
    36
    +
    
    37
    +
    
    38
    +# Test that error is raised when neither packges nor requirements files
    
    39
    +# have been specified
    
    40
    +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-packages'))
    
    41
    +def test_no_packages(cli, tmpdir, datafiles):
    
    42
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    43
    +    generate_project(project, tmpdir)
    
    44
    +    result = cli.run(project=project, args=[
    
    45
    +        'show', 'target.bst'
    
    46
    +    ])
    
    47
    +    result.assert_main_error(ErrorDomain.SOURCE, None)

  • tests/sources/pip/first-source-pip/target.bst
    ... ... @@ -2,3 +2,6 @@ kind: import
    2 2
     description: pip should not be allowed to be the first source
    
    3 3
     sources:
    
    4 4
     - kind: pip
    
    5
    +  python-exe: python3
    
    6
    +  packages:
    
    7
    +  - flake8

  • tests/sources/pip/no-packages/file
    1
    +Hello World!

  • tests/sources/pip/no-packages/target.bst
    1
    +kind: import
    
    2
    +description: The kind of this element is irrelevant.
    
    3
    +sources:
    
    4
    +- kind: local
    
    5
    +  path: file
    
    6
    +- kind: pip
    
    7
    +  python-exe: python3

  • tests/sources/pip/no-ref/target.bst
    ... ... @@ -4,3 +4,6 @@ sources:
    4 4
     - kind: local
    
    5 5
       path: file
    
    6 6
     - kind: pip
    
    7
    +  python-exe: python3
    
    8
    +  packages:
    
    9
    +  - flake8



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]