예제 #1
0
    def test_other(self):
        '''!
        Test when we call the constructor function using the product name
        '''

        id = Identifier('other')
        v = id.getIdentifier()
        assert (v == 'other')
예제 #2
0
    def test_serial_number(self):
        '''!
        Test when we call the constructor function using the serial number
        '''

        id = Identifier('serial-number')
        v = id.getIdentifier()
        assert (v == sysEeprom.get_serial_number())
예제 #3
0
    def test_product_name(self):
        '''!
        Test when we call the constructor function using the product name
        '''

        id = Identifier('product-name')
        v = id.getIdentifier()
        assert (v == sysEeprom.get_product_name())
예제 #4
0
    def test_hostname_fqdn(self):
        '''!
        Test when we call the constructor function using hostname-fqdn
        '''

        id = Identifier('hostname-fqdn')
        v = id.getIdentifier()
        assert (v == socket.getfqdn())
예제 #5
0
 def test_get_url5(self, tmpdir):
     dt = tmpdir.mkdir("valid")
     fh = dt.join("input.txt")
     content = '#!/bin/sh\n\necho "Hello"'
     fh.write(content)
     dl = [('url', None)]
     d = dict(dl)
     id = Identifier(d)
     v = id.getIdentifier()
     assert (v == None)
예제 #6
0
 def test_get_url4(self, tmpdir):
     dt = tmpdir.mkdir("valid")
     fh = dt.join("input.txt")
     content = '#!/bin/sh\nexit -1'
     fh.write(content)
     dl_url = [('source', 'file://' + str(fh)), ('destination', 'abc')]
     d_url = dict(dl_url)
     dl = [('url', d_url)]
     d = dict(dl)
     id = Identifier(d)
     v = id.getIdentifier()
     assert (v == None)
예제 #7
0
    def test_sonic_version(self):
        '''!
        Test when we call the constructor function using sonic-version
        '''

        id = Identifier('sonic-version')
        v = id.getIdentifier()
        build_version = None
        with open('/etc/sonic/sonic_version.yml') as fp:
            line = fp.readline()
            while line:
                version_info = line.split(':')
                if version_info[0] == 'build_version':
                    ver = version_info[1].strip()
                    ver = ver.lstrip('\'')
                    ver = ver.rstrip('\'')
                    build_version = 'SONiC.{}'.format(ver)
                    break
                line = fp.readline()
        fp.close()
        assert (v == build_version)
예제 #8
0
 def test_wrong_parameter2(self):
     dl = [('url', [1])]
     d = dict(dl)
     id = Identifier(d)
     v = id.getIdentifier()
     assert (v == None)