Beispiel #1
0
    def test_from_dict_wrong_dependencies_arguments(self):

        with self.assertRaises(MLIOPackWrongFormat):
            PackManifest.from_dict({
                'version': 2,
                'dependencies': {
                    'test': {
                        'type': 'module-version'
                    }
                }
            })
Beispiel #2
0
    def test_from_dict_wrong_dependencies_type(self):

        with self.assertRaises(MLIOPackWrongFormat):
            PackManifest.from_dict({
                'version': 2,
                'dependencies': {
                    'test': {
                        'type': 'unknown'
                    }
                }
            })
Beispiel #3
0
    def test_from_dict_wrong_dependencies_id(self):

        with self.assertRaises(MLIOPackWrongFormat):
            PackManifest.from_dict({
                'version': 2,
                'dependencies': {
                    'test': {
                        'type': 'module-version',
                        'module_name': 'tests',
                        'version_specs': '==1.1.0'
                    }
                }
            })
Beispiel #4
0
    def test_from_dict(self):
        creation_time = datetime(2017,
                                 1,
                                 1,
                                 0,
                                 2,
                                 2,
                                 tzinfo=timezone(timedelta(0)))
        updated_time = datetime(2018,
                                1,
                                1,
                                0,
                                2,
                                2,
                                tzinfo=timezone(timedelta(0)))

        manifest = PackManifest.from_dict(self.manifest_dict)

        self.assertListEqual(sorted(manifest.slots.keys()), ['slot1', 'slot2'])
        self.assertEqual(manifest.slots['slot1'].slot_key, 'slot1')
        self.assertListEqual(
            sorted(manifest.slots['slot1'].dependencies.keys()), [
                'module-version:anothermodule-<=2.2.0,>=1.1.0',
                'module-version:themodule-==1.1.0'
            ])

        self.assertEqual(manifest.slots['slot2'].slot_key, 'slot2')
        self.assertListEqual(
            sorted(manifest.slots['slot2'].dependencies.keys()),
            ['module-version:anothermodule-<=2.2.0,>=1.1.0'])

        self.assertListEqual(sorted(manifest.dependencies.keys()), [
            'module-version:anothermodule-<=2.2.0,>=1.1.0',
            'module-version:themodule-==1.1.0'
        ])
        self.assertEqual(
            manifest.dependencies['module-version:themodule-==1.1.0'].
            dependency_id(), 'module-version:themodule-==1.1.0')
        self.assertEqual(manifest.created_at, creation_time)
        self.assertEqual(manifest.updated_at, updated_time)
Beispiel #5
0
    def test_from_dict_wrong_slots_container(self):

        with self.assertRaises(MLIOPackWrongFormat):
            PackManifest.from_dict({'version': 2, 'slots': []})
Beispiel #6
0
    def test_from_dict_wrong_version(self):

        with self.assertRaises(MLIOPackWrongFormat):
            PackManifest.from_dict({'version': 1})
Beispiel #7
0
    def test_from_dict_bare_minimum(self):

        manifest = PackManifest.from_dict({'version': 2})
        self.assertDictEqual(manifest.slots, {})
        self.assertDictEqual(manifest.dependencies, {})