Exemplo n.º 1
0
    def test_register_and_find(self):
        '''
        Test that License classes can be registered with id
        '''
        class FooLicense(base.License):
            id = 'FOO'

        licenraptor.register(FooLicense)
        assert licenraptor.find('FOO') == FooLicense
Exemplo n.º 2
0
 def test_header(self, id):
     '''
     Test that License classes with header render it
     '''
     email = '*****@*****.**'
     header = licenraptor.find(id).header(name='Petr Foo', email=email)
     assert email in header
     assert str(date.today().year) in header
     assert 'This program is free software' in header
Exemplo n.º 3
0
    def test_render(self, name):
        '''
        Test that License classes can render it's files
        '''
        email = '*****@*****.**'

        text = licenraptor.find('MIT').render(name=name, email=email)

        assert name in text
        assert email in text
        assert str(date.today().year) in text
        assert 'Permission is hereby granted' in text
Exemplo n.º 4
0
 def test_register_find_custom_license(self):
     '''
     Test that custom license can be registered and found
     '''
     try:
         licenraptor.register(self.custom_cls)
         assert licenraptor.find('CUSTOM') == self.custom_cls
     finally:
         # unregister, just in case
         try:
             del licenraptor.core._db['CUSTOM']
         except:
             pass
Exemplo n.º 5
0
 def test_exisitng(self, id):
     '''
     Test that an exisitng license can be found
     '''
     assert licenraptor.find(id).id == id
Exemplo n.º 6
0
 def test_nonexisting(self):
     '''
     Test that non-existing license cannot be found
     '''
     with pytest.raises(KeyError):
         licenraptor.find('This is not an existing SPDX identifier')
Exemplo n.º 7
0
 def test_render_undefined(self):
     '''
     Test that License classes will fail to render without all variables defined
     '''
     with pytest.raises(jinja2.UndefinedError):
         licenraptor.find('MIT').render(name='xx')
Exemplo n.º 8
0
 def test_header_no_template(self):
     '''
     Test that License classes without header templates raise AttributeError during .header()
     '''
     with pytest.raises(AttributeError):
         header = licenraptor.find('MIT').header()