コード例 #1
0
ファイル: utils.py プロジェクト: flopezag/fiware-glancesync
    def dump(self):
        expectedkey = ['id', 'name', 'status', 'message']
        expectedvalue = [self.id, self.name, self.status, self.message]

        my_dict = fifo(expectedkey, expectedvalue)

        return my_dict.dump()
コード例 #2
0
    def test_create_ordered_dict_with_repeated_key(self):
        keys = ['id', 'id', 'status', 'message']
        values = [
            'a fake id 1', 'a fake id 2', 'a fake status', 'a fake message'
        ]

        expectedkeys = ['id', 'status', 'message']
        expectedvalues = ['a fake id 2', 'a fake status', 'a fake message']

        my_dict = fifo()

        for i in range(0, 4):
            my_dict.__setitem__(keys[i], values[i])

        i = 0
        for k, v in my_dict.iteritems():
            self.assertEqual(
                k, expectedkeys[i],
                "Expected key: {} is not the obtained key: {}".format(
                    k, expectedkeys[i]))

            self.assertEqual(
                v, expectedvalues[i],
                "Expected value: {} is not the obtained value: {}".format(
                    v, expectedvalues[i]))
            i = i + 1
コード例 #3
0
ファイル: utils.py プロジェクト: Fiware/ops.Glancesync
    def dump(self):
        expectedkey = ['id', 'name', 'status', 'message']
        expectedvalue = [self.id, self.name, self.status, self.message]

        my_dict = fifo(expectedkey, expectedvalue)

        return my_dict.dump()
コード例 #4
0
    def test_create_json(self):
        my_dict = fifo()

        for i in range(0, 4):
            my_dict.__setitem__(self.expectedkey[i], self.expectedvalue[i])

        jsontext = my_dict.dump()
        self.assertTrue(self.expectedjson, jsontext)
コード例 #5
0
ファイル: test_mydict.py プロジェクト: Fiware/ops.Glancesync
    def test_create_json(self):
        my_dict = fifo()

        for i in range(0, 4):
            my_dict.__setitem__(self.expectedkey[i], self.expectedvalue[i])

        jsontext = my_dict.dump()
        self.assertTrue(self.expectedjson, jsontext)
コード例 #6
0
ファイル: test_mydict.py プロジェクト: Fiware/ops.Glancesync
    def test_create_with_wrong_arrays2(self):
        expectedkey = ['id', 'name', 'status', 'message']
        expectedvalue = ['3cfeaf3f0103b9637bb3fcfe691fce1e', 'base_ubuntu_14.04', 'ok', None, 'a fake value']

        try:
            my_dict = fifo(expectedkey, expectedvalue)
        except ValueError as error:
            errormessage = 'Incorrect range of data, expected 4 but was {} in second argument'\
                .format(len(expectedvalue))

            self.assertEqual(error.message, errormessage)
コード例 #7
0
    def test_create_with_wrong_arrays3(self):
        expectedkey = list()
        expectedvalue = '3cfeaf3f0103b9637bb3fcfe691fce1e'
        errormessage = 'Expected arguments should be instances of list classes'

        try:
            fifo(expectedkey, expectedvalue)
        except ValueError as error:
            self.assertEqual(error.message, errormessage)

        expectedkey = 2
        expectedvalue = list()

        try:
            fifo(expectedkey, expectedvalue)
        except ValueError as error:
            self.assertEqual(error.message, errormessage)

        expectedkey = 2
        expectedvalue = 'a fake'

        try:
            fifo(expectedkey, expectedvalue)
        except ValueError as error:
            self.assertEqual(error.message, errormessage)
コード例 #8
0
ファイル: test_mydict.py プロジェクト: Fiware/ops.Glancesync
    def test_create_with_wrong_arrays3(self):
        expectedkey = list()
        expectedvalue = '3cfeaf3f0103b9637bb3fcfe691fce1e'
        errormessage = 'Expected arguments should be instances of list classes'

        try:
            fifo(expectedkey, expectedvalue)
        except ValueError as error:
            self.assertEqual(error.message, errormessage)

        expectedkey = 2
        expectedvalue = list()

        try:
            fifo(expectedkey, expectedvalue)
        except ValueError as error:
            self.assertEqual(error.message, errormessage)

        expectedkey = 2
        expectedvalue = 'a fake'

        try:
            fifo(expectedkey, expectedvalue)
        except ValueError as error:
            self.assertEqual(error.message, errormessage)
コード例 #9
0
    def test_create_with_wrong_arrays1(self):
        expectedkey = ['id', 'name', 'status', 'message', 'fake']
        expectedvalue = [
            '3cfeaf3f0103b9637bb3fcfe691fce1e', 'base_ubuntu_14.04', 'ok', None
        ]

        try:
            my_dict = fifo(expectedkey, expectedvalue)
        except ValueError as error:
            errormessage = 'Incorrect range of data, expected 4 but was {} in first argument'\
                .format(len(expectedkey))

            self.assertEqual(error.message, errormessage)
コード例 #10
0
ファイル: test_mydict.py プロジェクト: Fiware/ops.Glancesync
    def test_create_with_arrays(self):
        expectedkey = ['id', 'name', 'status', 'message']
        expectedvalue = ['3cfeaf3f0103b9637bb3fcfe691fce1e', 'base_ubuntu_14.04', 'ok', None]

        my_dict = fifo(expectedkey, expectedvalue)

        i = 0
        for k, v in my_dict.iteritems():
            self.assertEqual(k, expectedkey[i],
                             "Expected key: {} is not the obtained key: {}".format(k, expectedkey[i]))

            self.assertEqual(v, expectedvalue[i],
                             "Expected value: {} is not the obtained value: {}".format(v, expectedvalue[i]))
            i = i + 1
コード例 #11
0
ファイル: test_mydict.py プロジェクト: Fiware/ops.Glancesync
    def test_create_ordered_dict(self):
        my_dict = fifo()

        for i in range(0, 4):
            my_dict.__setitem__(self.expectedkey[i], self.expectedvalue[i])

        i = 0
        for k, v in my_dict.iteritems():
            self.assertEqual(k, self.expectedkey[i],
                             "Expected key: {} is not the obtained key: {}".format(k, self.expectedkey[i]))

            self.assertEqual(v, self.expectedvalue[i],
                             "Expected value: {} is not the obtained value: {}".format(v, self.expectedvalue[i]))
            i = i + 1
コード例 #12
0
    def test_create_ordered_dict(self):
        my_dict = fifo()

        for i in range(0, 4):
            my_dict.__setitem__(self.expectedkey[i], self.expectedvalue[i])

        i = 0
        for k, v in my_dict.iteritems():
            self.assertEqual(
                k, self.expectedkey[i],
                "Expected key: {} is not the obtained key: {}".format(
                    k, self.expectedkey[i]))

            self.assertEqual(
                v, self.expectedvalue[i],
                "Expected value: {} is not the obtained value: {}".format(
                    v, self.expectedvalue[i]))
            i = i + 1
コード例 #13
0
    def test_create_with_arrays(self):
        expectedkey = ['id', 'name', 'status', 'message']
        expectedvalue = [
            '3cfeaf3f0103b9637bb3fcfe691fce1e', 'base_ubuntu_14.04', 'ok', None
        ]

        my_dict = fifo(expectedkey, expectedvalue)

        i = 0
        for k, v in my_dict.iteritems():
            self.assertEqual(
                k, expectedkey[i],
                "Expected key: {} is not the obtained key: {}".format(
                    k, expectedkey[i]))

            self.assertEqual(
                v, expectedvalue[i],
                "Expected value: {} is not the obtained value: {}".format(
                    v, expectedvalue[i]))
            i = i + 1
コード例 #14
0
ファイル: test_mydict.py プロジェクト: Fiware/ops.Glancesync
    def test_create_ordered_dict_with_repeated_key(self):
        keys = ['id', 'id', 'status', 'message']
        values = ['a fake id 1', 'a fake id 2', 'a fake status', 'a fake message']

        expectedkeys = ['id', 'status', 'message']
        expectedvalues = ['a fake id 2', 'a fake status', 'a fake message']

        my_dict = fifo()

        for i in range(0, 4):
            my_dict.__setitem__(keys[i], values[i])

        i = 0
        for k, v in my_dict.iteritems():
            self.assertEqual(k, expectedkeys[i],
                             "Expected key: {} is not the obtained key: {}".format(k, expectedkeys[i]))

            self.assertEqual(v, expectedvalues[i],
                             "Expected value: {} is not the obtained value: {}".format(v, expectedvalues[i]))
            i = i + 1