コード例 #1
0
    def test_explicit_content(self):
        slot_dict = OrderedDict({"interface": "content", "content": "content-test"})
        slot_name = "slot-test"

        slot = ContentSlot.from_dict(slot_dict=slot_dict, slot_name=slot_name)

        assert slot_dict == slot.to_yaml_object()
コード例 #2
0
    def test_write_from_dict(self):
        slot_dict = OrderedDict({"interface": "content", "write": ["some/path"]})
        slot_name = "slot-test"

        slot = ContentSlot.from_dict(slot_dict=slot_dict, slot_name=slot_name)
        slot.validate()

        self.assertEqual(slot_dict, slot.to_yaml_object())
        self.assertEqual(slot_name, slot.slot_name)
        self.assertEqual(slot_dict["write"], slot.write)
        self.assertEqual(
            set(slot_dict["write"]), slot.get_content_dirs(installed_path="")
        )
コード例 #3
0
    def test_source_read_from_dict(self):
        slot_dict = OrderedDict({
            "interface": "content",
            "source": {
                "read": ["some/path"]
            }
        })
        slot_name = "slot-test"

        slot = ContentSlot.from_dict(slot_dict=slot_dict, slot_name=slot_name)
        slot.validate()

        self.assertEqual(slot_dict, slot.to_dict())
        self.assertEqual(slot_name, slot.slot_name)
        self.assertEqual(slot_dict["source"]["read"], slot.read)
        self.assertEqual(set(slot_dict["source"]["read"]),
                         slot.get_content_dirs(installed_path=""))
コード例 #4
0
    def test_write_from_dict_force_source_key(self):
        slot_dict = OrderedDict({"interface": "content", "write": ["some/path"]})
        slot_name = "slot-test"

        slot = ContentSlot.from_dict(slot_dict=slot_dict, slot_name=slot_name)
        slot.use_source_key = True
        slot.validate()
        transformed_dict = slot_dict.copy()
        transformed_dict["source"] = dict()
        transformed_dict["source"]["write"] = transformed_dict.pop("write")

        self.assertEqual(transformed_dict, slot.to_yaml_object())
        self.assertEqual(slot_name, slot.slot_name)
        self.assertEqual(slot_dict["write"], slot.write)
        self.assertEqual(
            set(slot_dict["write"]), slot.get_content_dirs(installed_path="")
        )
コード例 #5
0
ファイル: test_slots.py プロジェクト: siggiskulason/snapcraft
    def test_read_from_dict(self):
        slot_dict = OrderedDict({
            "interface": "content",
            "content": "explicit-content",
            "read": ["some/path"],
        })
        slot_name = "slot-test"

        slot = ContentSlot.from_dict(slot_dict=slot_dict, slot_name=slot_name)
        slot.validate()

        self.assertEqual(slot_dict, slot.to_yaml_object())
        self.assertEqual(slot_name, slot.slot_name)
        self.assertEqual(slot_dict["read"], slot.read)
        self.assertEqual(set(slot_dict["read"]),
                         slot.get_content_dirs(installed_path=""))
        self.assertEqual(slot_dict["content"], slot.content)